Package: python-launchpadlib
Version: 1.11.0-2
Severity: normal
Tags: patch
User: [email protected]
Usertags: origin-ubuntu noble ubuntu-patch
Hi Stefano,
As an Ubuntu developer and regular user of launchpadlib-based tools, one of
the usability issues I've noticed over time is that the launchpadlib cache
grows without bounds. I had cleaned up my directory at some point in the
past year; and as of today, it's 7.8GiB.
Now that systemd units are a thing, we can reasonably provide support by
default in the packaging to expire out the contents of these per-user cache
directories.
Please find attached a patch that implements a systemd service and timer
unit to expire out files from the cache that are over 30 days old.
Running this on my own system has reduced the cache size from 7.8GiB to
2.8GiB.
I have uploaded this change to Ubuntu.
Thanks for considering,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer https://www.debian.org/
[email protected] [email protected]
diff -Nru python-launchpadlib-1.11.0/debian/launchpadlib-cache-clean.service
python-launchpadlib-1.11.0/debian/launchpadlib-cache-clean.service
--- python-launchpadlib-1.11.0/debian/launchpadlib-cache-clean.service
1969-12-31 16:00:00.000000000 -0800
+++ python-launchpadlib-1.11.0/debian/launchpadlib-cache-clean.service
2024-01-20 14:42:10.000000000 -0800
@@ -0,0 +1,6 @@
+[Unit]
+Description=Clean up old files in the Launchpadlib cache
+
+[Service]
+Type=oneshot
+ExecStart=find %h/.launchpadlib/api.launchpad.net/cache -type f -mtime +30
-delete
diff -Nru python-launchpadlib-1.11.0/debian/launchpadlib-cache-clean.timer
python-launchpadlib-1.11.0/debian/launchpadlib-cache-clean.timer
--- python-launchpadlib-1.11.0/debian/launchpadlib-cache-clean.timer
1969-12-31 16:00:00.000000000 -0800
+++ python-launchpadlib-1.11.0/debian/launchpadlib-cache-clean.timer
2024-01-20 14:42:10.000000000 -0800
@@ -0,0 +1,9 @@
+[Unit]
+Description=Clean up old files in the Launchpadlib cache
+
+[Timer]
+OnStartupSec=5min
+OnUnitActiveSec=1d
+
+[Install]
+WantedBy=timers.target
diff -Nru python-launchpadlib-1.11.0/debian/rules
python-launchpadlib-1.11.0/debian/rules
--- python-launchpadlib-1.11.0/debian/rules 2023-12-26 06:53:57.000000000
-0800
+++ python-launchpadlib-1.11.0/debian/rules 2024-01-20 14:42:10.000000000
-0800
@@ -23,3 +23,9 @@
override_dh_python3:
dh_python3 --no-guessing-deps
+
+override_dh_install:
+ dh_install
+ mkdir -p debian/python3-launchpadlib/usr/lib/systemd/user
+ cp debian/launchpadlib-cache-clean* \
+ debian/python3-launchpadlib/usr/lib/systemd/user/