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 cacheclass
|
||||||
from voussoirkit import configlayers
|
from voussoirkit import configlayers
|
||||||
from voussoirkit import pathclass
|
from voussoirkit import pathclass
|
||||||
|
from voussoirkit import progressbars
|
||||||
from voussoirkit import ratelimiter
|
from voussoirkit import ratelimiter
|
||||||
from voussoirkit import spinal
|
from voussoirkit import spinal
|
||||||
from voussoirkit import sqlhelpers
|
from voussoirkit import sqlhelpers
|
||||||
|
@ -856,9 +857,16 @@ class PDBUtilMixin:
|
||||||
return photo
|
return photo
|
||||||
|
|
||||||
log.loud('Hashing file %s to check for rename.', filepath)
|
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(
|
sha256 = spinal.hash_file(
|
||||||
filepath,
|
filepath,
|
||||||
hash_class=hashlib.sha256, **hash_kwargs,
|
hash_class=hashlib.sha256, **hash_kwargs,
|
||||||
|
progressbar=progressbar,
|
||||||
).hexdigest()
|
).hexdigest()
|
||||||
|
|
||||||
same_hash = self.get_photos_by_hash(sha256)
|
same_hash = self.get_photos_by_hash(sha256)
|
||||||
|
|
|
@ -7,6 +7,7 @@ from voussoirkit import betterhelp
|
||||||
from voussoirkit import interactive
|
from voussoirkit import interactive
|
||||||
from voussoirkit import pathclass
|
from voussoirkit import pathclass
|
||||||
from voussoirkit import pipeable
|
from voussoirkit import pipeable
|
||||||
|
from voussoirkit import progressbars
|
||||||
from voussoirkit import ratelimiter
|
from voussoirkit import ratelimiter
|
||||||
from voussoirkit import spinal
|
from voussoirkit import spinal
|
||||||
from voussoirkit import stringtools
|
from voussoirkit import stringtools
|
||||||
|
@ -460,7 +461,7 @@ def reload_metadata_argparse(args):
|
||||||
|
|
||||||
hash_kwargs = {
|
hash_kwargs = {
|
||||||
'bytes_per_second': args.hash_bytes_per_second,
|
'bytes_per_second': args.hash_bytes_per_second,
|
||||||
'callback_progress': spinal.callback_progress_v1,
|
'progressbar': progressbars.Bar1_bytestring,
|
||||||
}
|
}
|
||||||
|
|
||||||
need_commit = False
|
need_commit = False
|
||||||
|
|
Loading…
Reference in a new issue