mirror of
https://github.com/aphrody-labs/msys2-devtools.git
synced 2026-10-17 12:35:12 +00:00
repo-prune: group packages with signatures
Ever since the download scripts copies over the original mtime from CI to the package, the mtimes of the package file and the signature files diverge. Since the prune script only goes by mtime this means packages get removed before signatures and which leads to some stray signature files on the server from time to time. Only delete a file if all existing related files should also be deleted. Fixes #8
This commit is contained in:
1 parent
137545bf05
commit
06adc05db4
1 file changed
+18
@@ -166,6 +166,24 @@ def get_files_to_prune(target_dir, time_delta):
|
||||
for group in group_by_package_name_and_ext(entries):
|
||||
paths_to_delete.update(group_get_paths_too_old(group, not_to_delete))
|
||||
|
||||
def get_related_files(path: str) -> list[str]:
|
||||
"""Returns a list of related files which should be deleted together with the given file"""
|
||||
|
||||
if not path.endswith(".sig"):
|
||||
return [path + ".sig"]
|
||||
else:
|
||||
return [path[:-4]]
|
||||
|
||||
def related_also_to_delete(path: str) -> bool:
|
||||
"""Returns True if all related files are also to be deleted, or don't exist"""
|
||||
|
||||
for related in get_related_files(path):
|
||||
if related not in paths_to_delete and os.path.exists(related):
|
||||
return False
|
||||
return True
|
||||
|
||||
paths_to_delete = set(p for p in paths_to_delete if related_also_to_delete(p))
|
||||
|
||||
return paths_to_delete
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user