Use progressbar for hashing of large files.
This commit is contained in:
parent
a2ad5ef930
commit
4bde199dbc
2 changed files with 10 additions and 1 deletions
|
@ -17,6 +17,7 @@ from . import tag_export
|
|||
from voussoirkit import cacheclass
|
||||
from voussoirkit import configlayers
|
||||
from voussoirkit import pathclass
|
||||
from voussoirkit import progressbars
|
||||
from voussoirkit import ratelimiter
|
||||
from voussoirkit import spinal
|
||||
from voussoirkit import sqlhelpers
|
||||
|
@ -856,9 +857,16 @@ class PDBUtilMixin:
|
|||
return photo
|
||||
|
||||
log.loud('Hashing file %s to check for rename.', filepath)
|
||||
|
||||
if filepath.size > 100 * (2 ** 20):
|
||||
progressbar = progressbars.bar1_bytestring()
|
||||
else:
|
||||
progressbar = None
|
||||
|
||||
sha256 = spinal.hash_file(
|
||||
filepath,
|
||||
hash_class=hashlib.sha256, **hash_kwargs,
|
||||
progressbar=progressbar,
|
||||
).hexdigest()
|
||||
|
||||
same_hash = self.get_photos_by_hash(sha256)
|
||||
|
|
|
@ -7,6 +7,7 @@ from voussoirkit import betterhelp
|
|||
from voussoirkit import interactive
|
||||
from voussoirkit import pathclass
|
||||
from voussoirkit import pipeable
|
||||
from voussoirkit import progressbars
|
||||
from voussoirkit import ratelimiter
|
||||
from voussoirkit import spinal
|
||||
from voussoirkit import stringtools
|
||||
|
@ -460,7 +461,7 @@ def reload_metadata_argparse(args):
|
|||
|
||||
hash_kwargs = {
|
||||
'bytes_per_second': args.hash_bytes_per_second,
|
||||
'callback_progress': spinal.callback_progress_v1,
|
||||
'progressbar': progressbars.Bar1_bytestring,
|
||||
}
|
||||
|
||||
need_commit = False
|
||||
|
|
Loading…
Reference in a new issue