Skip to content

Commit

Permalink
Only 1 build for non-dev branches
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Jul 16, 2024
1 parent 49663cc commit bd198bc
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions indexer/src/file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,23 @@ def move_files_for_indexed(dest_dir: str, source_dir: str, version_token: str) -
do_cleanup = True
else:
do_cleanup = True
pathlib.Path(dest_dir).mkdir(parents=True, exist_ok=True)
dest_path = pathlib.Path(dest_dir)
dest_path.mkdir(parents=True, exist_ok=True)
if do_cleanup:
files_per_build = len(os.listdir(source_dir))
builds_to_keep = 20
prev_files = [
entry.path
for entry in sorted(
os.scandir(dest_dir), key=lambda e: e.stat().st_mtime, reverse=True
)
]
cleanup_files = prev_files[files_per_build * builds_to_keep :]
for cleanup_file in cleanup_files:
os.remove(cleanup_file)
if dest_path.name == "dev":
files_per_build = len(os.listdir(source_dir))
builds_to_keep = 20
prev_files = [
entry.path
for entry in sorted(
os.scandir(dest_dir), key=lambda e: e.stat().st_mtime, reverse=True
)
]
cleanup_files = prev_files[files_per_build * builds_to_keep :]
for cleanup_file in cleanup_files:
os.remove(cleanup_file)
else:
cleanup_dir(dest_dir)
if version_token:
with open(token_file_path, "w") as token_file:
token_file.write(version_token)
Expand Down

0 comments on commit bd198bc

Please sign in to comment.