aboutsummaryrefslogtreecommitdiff
path: root/scripts/worker.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/worker.py')
-rw-r--r--scripts/worker.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/scripts/worker.py b/scripts/worker.py
index 0ef5ae5..ecdfaa2 100644
--- a/scripts/worker.py
+++ b/scripts/worker.py
@@ -1,6 +1,7 @@
import os
import sys
from typing import Callable
+from zipfile import Path, ZipFile, is_zipfile
import jsonpickle
from redis import Redis
@@ -64,6 +65,10 @@ def make_user_aborted(redis_conn, job_id):
return user_aborted
return __aborted__
+def get_zipfile_size(filepath):
+ with ZipFile(filepath, "r") as zfile:
+ return zfile.infolist()[0].file_size
+
def main():
args = process_cli_arguments()
if args is None:
@@ -72,7 +77,8 @@ def main():
with Redis.from_url(args.redisurl) as redis_conn:
progress_calculator = make_progress_calculator(
- os.stat(args.filepath).st_size)
+ get_zipfile_size(args.filepath) if is_zipfile(args.filepath)
+ else os.stat(args.filepath).st_size)
progress_indicator = make_progress_indicator(
redis_conn, args.job_id, progress_calculator)
count = args.count