progress: properly report on dir with large dirs

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-10-17 07:50:28 +03:00
parent 16fef9bb87
commit 7adafd0b5c
+6 -5
View File
@@ -158,14 +158,15 @@ class RemoteLOCAL(RemoteBase):
def collect_dir_cache(self, dname):
dir_info = []
bar = False
for root, dirs, files in os.walk(dname):
bar = False
if len(files) > LARGE_DIR_SIZE:
msg = "Computing md5 for a large directory {}. " \
"This is only done once."
Logger.info(msg.format(os.path.relpath(dname)))
Logger.info(msg.format(os.path.relpath(root)))
bar = True
title = os.path.relpath(dname)
title = os.path.relpath(root)
processed = 0
total = len(files)
progress.update_target(title, 0, total)
@@ -182,8 +183,8 @@ class RemoteLOCAL(RemoteBase):
dir_info.append({self.PARAM_RELPATH: relpath,
self.PARAM_MD5: md5})
if bar:
progress.finish_target(title)
if bar:
progress.finish_target(title)
# NOTE: sorting the list by path to ensure reproducibility
dir_info = sorted(dir_info, key=itemgetter(self.PARAM_RELPATH))