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 <junfeng.li@windriver.com>
This commit is contained in:
junfeng-li 2024-02-15 21:12:08 +00:00
parent 63b4a741c9
commit b662112b99
1 changed files with 12 additions and 0 deletions

View File

@ -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: