diff --git a/data/model/legacy.py b/data/model/legacy.py index d9b693630..0ac383bed 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -1579,13 +1579,19 @@ def list_repository_tags(namespace_name, repository_name, include_hidden=False): def _garbage_collect_tags(namespace_name, repository_name): + inner = (RepositoryTag + .select(RepositoryTag.id, + RepositoryTag.lifetime_end_ts, + RepositoryTag.repository) + .alias('rt')) to_delete = (RepositoryTag - .select(RepositoryTag.id) - .join(Repository) + .select(inner.c.id) + .from_(inner) + .join(Repository, on=(inner.c.repository_id == Repository.id)) .join(Namespace, on=(Repository.namespace_user == Namespace.id)) .where(Repository.name == repository_name, Namespace.username == namespace_name, - ~(RepositoryTag.lifetime_end_ts >> None), - (RepositoryTag.lifetime_end_ts + Namespace.removed_tag_expiration_s) <= + ~(inner.c.lifetime_end_ts >> None), + (inner.c.lifetime_end_ts + Namespace.removed_tag_expiration_s) <= int(time.time()))) (RepositoryTag