Feature Proposal: Automatic Package Cleanup – "Vacuum" Option in Aqua #3086
Replies: 1 comment 1 reply
-
Thank you for your detailed proposal!
Executing commands managed by aqua should be fast, so we don't want to add the overhead as much as possible.
aqua has the concept of the global configuration file, but this is for installing tools globally and not for global settings. e.g. export AQUA_VACUUM_DAYS=30
Multiple commands managed by aqua may be executed in parallel, so if they write to the same text file such as
e.g.
|
Beta Was this translation helpful? Give feedback.
-
I'd like to propose a new feature for Aqua called "Vacuum", which would automatically clean up unused packages or versions after N days of inactivity.
Feature Overview:
This feature would add a configurable option, such as vacuum: true or vacuum_days: N, in Aqua’s global configuration. Every time a command managed by Aqua is executed, the cleanup task would be triggered. The goal is to maintain a clean environment by automatically uninstalling packages and versions that haven’t been used for a specified period of time.
Example:
Let’s say I have three versions of the gh CLI installed via Aqua—version 1.0.0, version 1.2.0, and version 1.5.0. Each time I use a specific version of gh through Aqua, a timestamp (last usage) would be stored or updated. Each version of every package will have its own timestamp.
Version 1.0.0 might be used frequently, so its timestamp is updated regularly.
Version 1.2.0 might not have been used in a while.
Version 1.5.0 might have been installed but never used.
If the vacuum_days: 30 option is set, and version 1.2.0 hasn’t been used for 30 days, Aqua would automatically uninstall that version. If version 1.5.0 has never been used, it would also be cleaned up. However, version 1.0.0 would remain available because it is used regularly.
Configuration Option:
Here’s an example of how the configuration could look in Aqua’s global settings:
This would enable the "Vacuum" feature and set the cleanup threshold to 30 days. Aqua would then perform the cleanup process whenever a command is executed.
Timestamp Storage Solution:
To keep track of installed packages and their last usage, Aqua can store a JSON or YAML file locally on the user’s machine (e.g., ~/.aqua/timestamps.json or ~/.aqua/timestamps.yaml). This file would record the installation time and last usage for each package and version.
Here’s an example structure of the file:
installed_at: Records the installation timestamp of a package version. (Or nil if not known)
last_used_at: Updates whenever a package version is invoked. If null, it means the package hasn’t been used yet.
How It Works in Go:
When Aqua starts, it reads the timestamps.json (or .yaml) file from the configuration directory. If the file doesn’t exist, it initializes it.
When a package is installed or used, the respective installed_at or last_used_at fields are updated and saved back to the file.
During execution, Aqua checks the timestamps, and if a package version hasn’t been used for more than the specified vacuum_days, it will be automatically uninstalled.
Benefits:
Keeps your environment clean and lightweight by removing unused packages.
Minimizes manual maintenance by automatically handling old or unused package versions.
Regularly used packages are kept available as their timestamps are updated frequently.
This proposal introduces the Vacuum feature for automatic cleanup of packages, and the local JSON/YAML storage of timestamps ensures a lightweight and autonomous solution for managing package usage data on a single machine.
What do you think about it ?
Beta Was this translation helpful? Give feedback.
All reactions