dhunter/core/file_hash_cache.py
def load(self) -> None:
        """Loads FileHashes from from flat file storage
        """
        if not os.path.isdir(self._path):
            raise NotADirectoryError('"{name}" is not a directory'.format(name=self._path))

        from .file_hash import FileHash

        # if we are forced to rehash all files, then we pretend
        # there was no file to load...
        if self._config.force_rehash:
            self._dirty = True
            return

        # we need to prevent dirty state as loading should not affect that flag at all
        dirty = self._dirty
        dot_file_name = os.path.join(self._path, Const.FILE_DOT_DHUNTER)

        if os.path.isfile(dot_file_name):
            # is header line read already?
            file_hash_meta_read = False

            with open(dot_file_name, 'r') as fh:
                for line in fh:
                    line = line.strip('\n').strip()

                    if not line or line[0] == '#':
                        continue

                    if not file_hash_meta_read:
                        # we need to read cache meta data. For now it is not really needed.
                        file_hash_meta_read = True
                        continue

                    filehash = FileHash(line, self._config, dir_path=self._path, no_hash_calc=True)
                    if filehash.exists():
                        self.add(filehash)
                    else:
                        from .log import Log
                        Log.w('File no longer exists: {}'.format(os.path.join(self._path, filehash.name)))
                        dirty = True

        self._dirty = dirty
Loads FileHashes from from flat file storage
        
Loads FileHashes from from flat file storage
Loads FileHashes from from flat file storage
def load(self) -> None:
        if not os.path.isdir(self._path):
            raise NotADirectoryError('"{name}" is not a directory'.format(name=self._path))
        from .file_hash import FileHash
        if self._config.force_rehash:
            self._dirty = True
            return
        dirty = self._dirty
        dot_file_name = os.path.join(self._path, Const.FILE_DOT_DHUNTER)
        if os.path.isfile(dot_file_name):
            file_hash_meta_read = False
            with open(dot_file_name, 'r') as fh:
                for line in fh:
                    line = line.strip('\n').strip()
                    if not line or line[0] == '#':
                        continue
                    if not file_hash_meta_read:
                        file_hash_meta_read = True
                        continue
                    filehash = FileHash(line, self._config, dir_path=self._path, no_hash_calc=True)
                    if filehash.exists():
                        self.add(filehash)
                    else:
                        from .log import Log
                        Log.w('File no longer exists: {}'.format(os.path.join(self._path, filehash.name)))
                        dirty = True
        self._dirty = dirty
def load ( self ) -> None : if not os . path . isdir ( self . _path ) : raise NotADirectoryError ( '"{name}" is not a directory' . format ( name = self . _path ) ) from . file_hash import FileHash if self . _config . force_rehash : self . _dirty = True return dirty = self . _dirty dot_file_name = os . path . join ( self . _path , Const . FILE_DOT_DHUNTER ) if os . path . isfile ( dot_file_name ) : file_hash_meta_read = False with open ( dot_file_name , 'r' ) as fh : for line in fh : line = line . strip ( '\n' ) . strip ( ) if not line or line [ 0 ] == '#' : continue if not file_hash_meta_read : file_hash_meta_read = True continue filehash = FileHash ( line , self . _config , dir_path = self . _path , no_hash_calc = True ) if filehash . exists ( ) : self . add ( filehash ) else : from . log import Log Log . w ( 'File no longer exists: {}' . format ( os . path . join ( self . _path , filehash . name ) ) ) dirty = True self . _dirty = dirty
Loads FileHashes from from flat file storage
Loads FileHashes from from flat file storage
"""Loads FileHashes from from flat file storage
        """ # if we are forced to rehash all files, then we pretend # there was no file to load... # we need to prevent dirty state as loading should not affect that flag at all # is header line read already? # we need to read cache meta data. For now it is not really needed.
self