aurweb/aurweb/scripts/pkgmaint.py
moson-mo 8d2e176c2f
housekeep: stop "pkgmaint" script (cron job)
With the removal of the "setup-repo" command this script becomes obsolete,
because it is not possible to reserve a repo anymore.
Hence we don't need cleanup.

We've also seen issues in case the last packager's user account is removed,
leading to the deletion of a Package.

Let's deactivate this for now.

Issue report: #425

Signed-off-by: moson-mo <mo-son@mailbox.org>
2023-02-21 11:19:02 +01:00

32 lines
767 B
Python
Executable file

#!/usr/bin/env python3
from sqlalchemy import and_
from aurweb import db, time
from aurweb.models import PackageBase
def _main():
# One day behind.
limit_to = time.utcnow() - 86400
query = db.query(PackageBase).filter(
and_(PackageBase.SubmittedTS < limit_to, PackageBase.PackagerUID.is_(None))
)
db.delete_all(query)
def main():
# Previously used to clean up "reserved" packages which never got pushed.
# Let's deactivate this for now since "setup-repo" is gone and we see
# other issue where deletion of a user account might cause unintended
# removal of a package (where PackagerUID account was deleted)
return
db.get_engine()
with db.begin():
_main()
if __name__ == "__main__":
main()