From 8de3710b7bb962e75cb76d3cc1bda74bc6daf16f Mon Sep 17 00:00:00 2001 From: Cristiano Urban Date: Thu, 16 Sep 2021 23:19:11 +0200 Subject: [PATCH] Fixed total file size calcution. Signed-off-by: Cristiano Urban --- transfer_service/retrieve_executor.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/transfer_service/retrieve_executor.py b/transfer_service/retrieve_executor.py index e4eba7d..d86bb52 100644 --- a/transfer_service/retrieve_executor.py +++ b/transfer_service/retrieve_executor.py @@ -131,6 +131,8 @@ class RetrieveExecutor(TaskExecutor): md5calc = Checksum() if os.path.isdir(srcPath): for root, dirs, files in os.walk(srcPath, topdown = False): + dirSize = os.stat(root).st_size + self.totalSize += dirSize for f in files: fullPath = os.path.join(root, f) if md5calc.fileIsValid(fullPath): @@ -142,6 +144,7 @@ class RetrieveExecutor(TaskExecutor): "fileSize": fileSize, "vospaceRootParent": vospacePath } + self.totalSize += fileSize self.fileList.append(fileInfo.copy()) else: if md5calc.fileIsValid(srcPath): @@ -153,14 +156,15 @@ class RetrieveExecutor(TaskExecutor): "fileSize": fileSize, "vospaceRootParent": vospacePath } + self.totalSize += fileSize self.fileList.append(fileInfo.copy()) - - # debug block... - #if os.path.exists("fileList.txt"): - # os.remove("fileList.txt") - #fl = open("fileList.txt", 'w') - #fl.write(json.dumps(self.fileList, indent = 4)) - #fl.close() + self.logger.info(f"Total size of files to retrieve: {self.totalSize} B") + # debug block... + #if os.path.exists("fileList.txt"): + # os.remove("fileList.txt") + #fl = open("fileList.txt", 'w') + #fl.write(json.dumps(self.fileList, indent = 4)) + #fl.close() except Exception: self.logger.exception("FATAL: something went wrong while building the list of the files to be retrieved.") return False @@ -179,7 +183,7 @@ class RetrieveExecutor(TaskExecutor): blockSize = 0 for fileInfo in self.fileList: fileSize = fileInfo["fileSize"] - self.totalSize += fileSize + #self.totalSize += fileSize # check if the file is larger than a block size if fileSize > self.maxBlockSize: # if the current block is not empty, "close" it, otherwise -- GitLab