Skip to content

Commit 0b5732d

Browse files
Merge pull request #2 from b97pla/feature/use_optional_path_parameter
if specified, use a supplied path to the pdc archive
2 parents 61672b0 + 4edd114 commit 0b5732d

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
__pycache__
33
*.swp
44
*.swo
5+
.idea/

archive_verify/handlers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ async def verify(request):
2525
host = body["host"]
2626
archive = body["archive"]
2727
description = body["description"]
28-
28+
path = body.get("path")
29+
2930
src_root = request.app["config"]["pdc_root_dir"].format(host)
30-
archive_path = os.path.join(src_root, archive)
31+
# use a supplied path if available, otherwise construct it from the src_root and archive
32+
archive_path = path or os.path.join(src_root, archive)
3133

3234
redis_conn = Redis()
3335
q = Queue(connection=redis_conn)
@@ -38,7 +40,7 @@ async def verify(request):
3840
# config e.g. setups the queue to keep the job results indefinately,
3941
# therefore they we will have to remove them ourselves afterwards.
4042
job = q.enqueue_call(verify_archive,
41-
args=(archive, host, description, request.app["config"]),
43+
args=(archive, archive_path, description, request.app["config"]),
4244
timeout=request.app["config"]["job_timeout"],
4345
result_ttl=request.app["config"]["job_result_ttl"],
4446
ttl=request.app["config"]["job_ttl"])

archive_verify/workers.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,24 @@ def compare_md5sum(archive_dir):
9090
else:
9191
return True
9292

93-
def verify_archive(archive, host, description, config):
93+
def verify_archive(archive, archive_path, description, config):
9494
"""
9595
Our main worker function. This will be put into the RQ/Redis queue when the /verify endpoint gets called.
9696
Downloads the specified archive from PDC and then verifies the MD5 sums.
9797
9898
:param archive: The name of the archive we shall download
99-
:param host: The host the archive was previsouly uploaded from
99+
:param archive_path: The path to the archive on PDC
100100
:param description: The unique description that was used when uploading the archive to PDC
101101
:param config: A dict containing the apps configuration
102102
:returns A JSON with the result that will be kept in the Redis queue
103103
"""
104104
dest_root = config["verify_root_dir"]
105105
dsmc_log_dir = config["dsmc_log_dir"]
106106
whitelist = config["whitelisted_warnings"]
107-
src_root = config["pdc_root_dir"].format(host)
108-
src = os.path.join(src_root, archive)
109107
job_id = rq.get_current_job().id
110108
dest = "{}_{}".format(os.path.join(dest_root, archive), job_id)
111109

112-
download_ok = download_from_pdc(src, description, dest, dsmc_log_dir, whitelist)
110+
download_ok = download_from_pdc(archive_path, description, dest, dsmc_log_dir, whitelist)
113111

114112
if not download_ok:
115113
return {"state": "error", "msg": "failed to properly download archive from pdc", "path": dest}

0 commit comments

Comments
 (0)