X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6e75a30246598a40cabb8ca1498c3a4f6f146c91..5c3f2f665243a32510f8097bf6c0582fc14d2fd3:/apps/catalogue/utils.py?ds=sidebyside diff --git a/apps/catalogue/utils.py b/apps/catalogue/utils.py index 3a8d1b027..0134701a6 100644 --- a/apps/catalogue/utils.py +++ b/apps/catalogue/utils.py @@ -90,6 +90,7 @@ class LockFile(object): self.lock.close() +@task def create_zip(paths, zip_slug): """ Creates a zip in MEDIA_ROOT/zip directory containing files from path. @@ -110,8 +111,10 @@ def create_zip(paths, zip_slug): if not path.exists(path.join(zip_path, zip_filename)): zipf = ZipFile(path.join(zip_path, zip_filename), 'w') try: - for p in paths: - zipf.write(p, path.basename(p)) + for arcname, p in paths: + if arcname is None: + arcname = path.basename(p) + zipf.write(p, arcname) finally: zipf.close() @@ -128,8 +131,3 @@ def remove_zip(zip_slug): except OSError as oe: if oe.errno != ENOENT: raise oe - - -@task -def create_zip_task(*args): - return create_zip(*args)