cleanup_old_backups


Description:

public static async void cleanup_old_backups (Database db, int max_deleted_days = 30)

Cleanup old backup files from the backup directory and database records.

Removes backup files and database records older than max_deleted_days from ~/.cache/ollmchat/edited/ and the database.

This method: 1. Selects FileHistory records older than max_deleted_days 2. Deletes database records (filebase and file_history) 3. Deletes backup files from disk

This should be called on startup or periodically to prevent backup directory and database from growing indefinitely.

Only runs once per day to avoid excessive file system and database operations.

Parameters:

db

Database instance (required)

max_deleted_days

Number of days to retain deleted file records (default: 30 if <= 0)