From ee1406f72357748c5cae2bf813ee22cdb9f475a1 Mon Sep 17 00:00:00 2001 From: Joshua Hesketh Date: Tue, 3 Feb 2015 10:57:01 +1100 Subject: [PATCH] Sort filenames in swift indexes Sort the folders first then the file list for swift indexes. The sorted() function runs on the whole path even though only the basename is displayed. This will still result in the correct order though as the folder paths will be identical. Change-Id: I9c9eb7abad121f23884d58c17771be412e7614c2 --- jenkins/scripts/zuul_swift_upload.py | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/jenkins/scripts/zuul_swift_upload.py b/jenkins/scripts/zuul_swift_upload.py index 58321e04a7..9a7dedec9f 100755 --- a/jenkins/scripts/zuul_swift_upload.py +++ b/jenkins/scripts/zuul_swift_upload.py @@ -235,24 +235,7 @@ def build_file_list(file_path, logserver_prefix, swift_destination_prefix, folder_links.append(file_details) - for f in files: - filename = os.path.basename(f) - full_path = os.path.join(path, filename) - relative_name = os.path.relpath(full_path, parent_dir) - url = os.path.join(destination_prefix, relative_name) - - file_details = { - 'filename': filename, - 'path': full_path, - 'relative_name': relative_name, - 'url': url, - 'metadata': get_file_metadata(full_path), - } - - file_list.append(file_details) - folder_links.append(file_details) - - for f in folders: + for f in sorted(folders): filename = os.path.basename(f) + '/' full_path = os.path.join(path, filename) relative_name = os.path.relpath(full_path, parent_dir) @@ -269,6 +252,23 @@ def build_file_list(file_path, logserver_prefix, swift_destination_prefix, folder_links.append(file_details) + for f in sorted(files): + filename = os.path.basename(f) + full_path = os.path.join(path, filename) + relative_name = os.path.relpath(full_path, parent_dir) + url = os.path.join(destination_prefix, relative_name) + + file_details = { + 'filename': filename, + 'path': full_path, + 'relative_name': relative_name, + 'url': url, + 'metadata': get_file_metadata(full_path), + } + + file_list.append(file_details) + folder_links.append(file_details) + if create_dir_indexes: full_path = make_index_file( folder_links,