From 20e5c3de499aee0febf47d81fbea2296a1ad5d1c Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 28 Apr 2024 01:24:17 +0100 Subject: [PATCH] Show correct files with --nobuild --- indexer/src/parsers.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/indexer/src/parsers.py b/indexer/src/parsers.py index bbb59f5..a8e82b2 100644 --- a/indexer/src/parsers.py +++ b/indexer/src/parsers.py @@ -28,7 +28,11 @@ def add_files_to_version( logging.exception(exception_msg) raise Exception(exception_msg) - for cur in sorted(os.listdir(directory_path)): + latest_version = None + for entry in sorted( + os.scandir(directory_path), key=lambda e: e.stat().st_mtime, reverse=True + ): + cur = entry.name # skip .DS_store files if cur.startswith("."): continue @@ -40,6 +44,13 @@ def add_files_to_version( except Exception as e: logging.exception(e) continue + if latest_version is None: + match = file_parser.regex.match(cur) + latest_version = "mntm-" + match.group(3) + if not version.version.startswith("mntm-"): + version.version = latest_version.removeprefix("mntm-dev-") + elif latest_version not in cur: + continue version.add_file( VersionFile( url=os.path.join(settings.base_url, main_dir, сhannel_dir, cur),