Verified Commit 5e61ca19 authored by anarcat's avatar anarcat
Browse files

hide all dangerous folders under a single dangerzone/ folder

Right now we have `dangerzene-processed/`, `dangerzone-rejected/`,
`dangerzone-processing/`... that's noisy, at best, and dangerous, at
worst: at least one user thought that `dangerzone-processed` was where
processed (so: safe) files ended up.

Just have `dangerzone/` and `safe/` folders at the toplevel, with the
`processed/`, `rejected/`, `processing/` stuff inside `dangerzone/`.

Closes: #4
parent 1a04b31a
......@@ -289,9 +289,12 @@ class DockerRunner(object):
# NOTE: do *not* add a trailing or leading slash to a SPECIAL_FOLDERS entry
# the `folder` param is stripped for a better check
SPECIAL_FOLDERS = (
# those are legacy and might eventually get removed
"dangerzone-processed",
"dangerzone-processing",
"dangerzone-rejected",
# those are actually in use
"dangerzone",
"safe"
)
......@@ -364,10 +367,11 @@ class ProcessingClient(wc.Client):
logging.info("sanitizing %s %s", folder, path)
# non-empty folder or regular file
if len(listing) > 1 or not path.endswith("/"):
remote_processing_path = folder + "/dangerzone-processing/" + path
logging.info("moving %s to %s before dangerzone-processing", path, remote_processing_path)
remote_processing_path = folder + "/dangerzone/processing/" + path
logging.info("moving %s to %s before dangerzone/processing", path, remote_processing_path)
if not self.dryrun:
self.mkdir(folder + "/dangerzone-processing")
self.mkdir(folder + "/dangerzone")
self.mkdir(folder + "/dangerzone/processing")
self.move(remote_path_from=folder + "/" + path, remote_path_to=remote_processing_path)
with tempfile.TemporaryDirectory() as tmpdir:
# TODO: sanitize path for local use
......@@ -398,7 +402,7 @@ class ProcessingClient(wc.Client):
remote_rejected_path,
)
if not self.dryrun:
self.mkdir(folder + "/dangerzone-rejected")
self.mkdir(folder + "/dangerzone/rejected")
self.move(
remote_path_from=remote_processing_path,
remote_path_to=remote_rejected_path,
......@@ -417,12 +421,12 @@ class ProcessingClient(wc.Client):
remote_path=remote_safe_path,
local_path=self.sanitizer.safe_dir,
)
remote_processed_path = folder + "/dangerzone-processed/" + path
remote_processed_path = folder + "/dangerzone/processed/" + path
logging.info(
"renaming %s to %s", remote_processing_path, remote_processed_path,
)
if not self.dryrun:
self.mkdir(folder + "/dangerzone-processed")
self.mkdir(folder + "/dangerzone/processed")
self.move(
remote_path_from=remote_processing_path,
remote_path_to=remote_processed_path,
......
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