dhunter/core/file_hash_cache.py
def add(self, file_hash: FileHash) -> None:
        """Add FileHash to internal cache storage

        :raises ValueError
        """
        if not isinstance(file_hash, FileHash):
            raise ValueError('Unsupported data type {type}'.format(type=type(file_hash)))

        # check if we have this hash entry in cache already?
        if file_hash not in self._cache.values():
            # no, create new entry then
            self._add_finalize(file_hash)
        elif file_hash.name in self._cache:
            # we do, so let's check if that is for this particular file state
            current_file_hash = self._cache.get(file_hash.name)
            if file_hash != current_file_hash:
                # seems it is not. Most likely underlying data changed,
                # while filename and/or size did not. Need to replace old
                # entry with new one then.

                # in case size changed, we need to keep cached totals up to date
                self._total_file_size -= current_file_hash.size

                # replace old object
                self.replace(file_hash.name)

                # update hash, and totals
                self._add_finalize(file_hash)
Add FileHash to internal cache storage

        :raises ValueError
        
Add FileHash to internal cache storage
:raises ValueError
Add FileHash to internal cache storage : raises ValueError
def add(self, file_hash: FileHash) -> None:
        if not isinstance(file_hash, FileHash):
            raise ValueError('Unsupported data type {type}'.format(type=type(file_hash)))
        if file_hash not in self._cache.values():
            self._add_finalize(file_hash)
        elif file_hash.name in self._cache:
            current_file_hash = self._cache.get(file_hash.name)
            if file_hash != current_file_hash:
                self._total_file_size -= current_file_hash.size
                self.replace(file_hash.name)
                self._add_finalize(file_hash)
def add ( self , file_hash : FileHash ) -> None : if not isinstance ( file_hash , FileHash ) : raise ValueError ( 'Unsupported data type {type}' . format ( type = type ( file_hash ) ) ) if file_hash not in self . _cache . values ( ) : self . _add_finalize ( file_hash ) elif file_hash . name in self . _cache : current_file_hash = self . _cache . get ( file_hash . name ) if file_hash != current_file_hash : self . _total_file_size -= current_file_hash . size self . replace ( file_hash . name ) self . _add_finalize ( file_hash )
Add FileHash to internal cache storage
:raises ValueError
Add FileHash to internal cache storage : raises ValueError
"""Add FileHash to internal cache storage

        :raises ValueError
        """ # check if we have this hash entry in cache already? # no, create new entry then # we do, so let's check if that is for this particular file state # seems it is not. Most likely underlying data changed, # while filename and/or size did not. Need to replace old # entry with new one then. # in case size changed, we need to keep cached totals up to date # replace old object # update hash, and totals
self
file_hash
FileHash