From b662112b99d9be7ce966d0eb10f2401638f300dc Mon Sep 17 00:00:00 2001 From: junfeng-li Date: Thu, 15 Feb 2024 21:12:08 +0000 Subject: [PATCH] Only allow one iso file being uploaded When using 'software upload-dir' to upload files , this commit will only allow one iso file or one signature to be uploaded in the directory. Multiple iso/signature files in the directory to be uploaded won't be permitted in order to prevent not enough disk space in /scratch directory in the active controller and wrong signature files being used. Test Plan: PASS: upload multiple iso files in the directory. PASS: upload one iso file in the directory. PASS: upload multiple sig files in the directory. PASS: upload one sig file in the directory. Task: 49576 Story: 2010676 Change-Id: Iba5af49ca50b4c836157027e140095a68ee5341b Signed-off-by: junfeng-li --- software-client/software_client/software_client.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/software-client/software_client/software_client.py b/software-client/software_client/software_client.py index c22e8209..cc086dd5 100644 --- a/software-client/software_client/software_client.py +++ b/software-client/software_client/software_client.py @@ -881,6 +881,18 @@ def release_upload_dir_req(args): print("No file to upload") return 0 + temp_iso_files = [f for f in raw_files if f.endswith(constants.ISO_EXTENSION)] + if len(temp_iso_files) > 1: # Verify that only one ISO file is being uploaded + print("Only one ISO file can be uploaded at a time. Found: %s" % + temp_iso_files, file=sys.stderr) + return 1 + + temp_sig_files = [f for f in raw_files if f.endswith(constants.SIG_EXTENSION)] + if len(temp_sig_files) > 1: # Verify that only one SIG file is being uploaded + print("Only one SIG file can be uploaded at a time. Found: %s" % + temp_sig_files, file=sys.stderr) + return 1 + for software_file in sorted(set(raw_files)): _, ext = os.path.splitext(software_file) if ext in constants.SUPPORTED_UPLOAD_FILE_EXT: