Verified Commit 9e7a6887 authored by anarcat's avatar anarcat
Browse files


parent f4e87443
......@@ -106,13 +106,15 @@ class BatchArgParser(argparse.ArgumentParser):
args = super().parse_args(*args, **kwargs)
if args.password is None:
args.password = getpass("Password:")
for attr in ('location', 'username', 'password'):
for attr in ("location", "username", "password"):
if not getattr(args, attr):
self.error("no %s provided, provide one with --%s or WEBDAV_%s environment" % (attr, attr, attr.upper()))
"no %s provided, provide one with --%s or WEBDAV_%s environment"
% (attr, attr, attr.upper())
return args
class Sanitizer:
"""actually sanitize files with Docker
......@@ -308,14 +310,14 @@ SPECIAL_FOLDERS = (
# those are actually in use
def is_special_folder(folder: str) -> bool:
"""Normalize `folder` and check if it's in `SPECIAL_FOLDERS`"""
return folder.strip('/') in SPECIAL_FOLDERS
return folder.strip("/") in SPECIAL_FOLDERS
def main():
......@@ -391,12 +393,17 @@ class ProcessingClient(wc.Client):
# non-empty folder or regular file
if len(listing) > 1 or not path.endswith("/"):
remote_processing_path = join(folder, "dangerzone/processing", path)"moving %s to %s before processing", path, remote_processing_path)
"moving %s to %s before processing", path, remote_processing_path
if not self.dryrun:
self.mkdir(join(folder, "dangerzone"))
self.mkdir(join(folder, "dangerzone/processing"))
self.move(remote_path_from=join(folder, path), remote_path_to=remote_processing_path)
remote_path_from=join(folder, path),
except ResponseErrorCode as e:
# actually used in WebDAV to show the file already exists
......@@ -457,12 +464,12 @@ class ProcessingClient(wc.Client):
remote_safe_directory = join(folder, "safe")
remote_safe_path = join(remote_safe_directory, path)
local_safe_path = join(self.sanitizer.safe_dir, path)"recursively creating remote safe directory {remote_safe_directory}")
if not self.dryrun:
"uploading %s to %s", local_safe_path, remote_safe_path
f"recursively creating remote safe directory {remote_safe_directory}"
if not self.dryrun:
self.mkdir_recursive(remote_safe_directory)"uploading %s to %s", local_safe_path, remote_safe_path)
if not self.dryrun:
# does that work when safe/ already has stuff?
......@@ -471,7 +478,9 @@ class ProcessingClient(wc.Client):
remote_processed_path = join(folder, "dangerzone/processed", path)
"renaming %s to %s", remote_processing_path, remote_processed_path,
"renaming %s to %s",
if not self.dryrun:
# TODO: turn "dangerzone/processed" into a constant
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment