Wrongly removes conan metadata files
Pro opened this issue · 2 comments
Thank you for your awesome tool!
We would like to use it for cleaning up a conan repository.
When the conan client deploys a package, it uploads:
- conan_package.tgz
At the same time, the server side generates some metadata (see also conan-io/conan#8418)
- .timestamp
- index.json
When dowloading a conan package, it only downloads package.tar.gz, but not the additional meta files.
If I now run the rules.delete_not_used_since(days=60),
rule on packages which were deployed before 60 days, but still regularly downloaded, it will delete the meta files, but keep the conan_package.tgz file. A conan package download does not trigger the download counter on the metadata files.
And this will invalidate the whole conan package (as also mentioned here jfrog/artifactory-user-plugins#319).
One solution would be to use rules.exclude_filename(['.timestamp', 'index.json'])
(also suggested here jfrog/artifactory-user-plugins#399).
This would then only delete the package, but not the metadata. And therefore, the metadata is never cleaned up... So also not the perfect solution.
Do you have any suggestions how to handle this?
I guess to solve this we would need dedicated rules just for conan, similar to the docker rules?
There may also other package types affected by this (e.g., npm, pypi, conda, debian, ...), see also jfrog/artifactory-user-plugins#319 (comment)
I found a solution:
- Delete any conan files, but keep the metadata
- Delete all directories which only contain metadata files and nothing else
This can be achieved like this, considering that you apply the MR proposed in #48
RULES = [
# ------ ALL REPOS --------
CleanupPolicy(
'Delete files older than 60 days',
rules.repo('conan-testing'),
rules.delete_not_used_since(days=60),
# Make sure to keep conan metadata. See also
# https://github.com/devopshq/artifactory-cleanup/issues/47
rules.exclude_filename(['.timestamp', 'index.json']),
),
CleanupPolicy(
'Delete empty folders',
rules.repo('conan-testing'),
rules.delete_empty_folder(),
# Exclude metadata files. I.e., if a folder only contains these files, consider it as
# empty
rules.exclude_filename(['.timestamp', 'index.json']),
),
]