Periodic database & attachments garbage collection: Bug #714134

See the ticket (comment #2) for more information on the thinking and
strategy here, but in a nutshell this will remove from the Geary
database all emails no longer accessible via any folder and not seen
on the server in over 30 days.  It also deletes those messages
attachment(s) and removes any empty directories in the attachment/
directory to prevent clutter.  If enough messages are garbage
collected, Geary will vacuum the database at startup, which will
lower its disk footprint and reduce fragmentation, potentially
increasing performance.
This commit is contained in:
Jim Nelson 2014-12-18 17:00:47 -08:00
parent a740b3f2f1
commit 23511dc36c
13 changed files with 760 additions and 7 deletions

25
sql/version-024.sql Normal file
View file

@ -0,0 +1,25 @@
--
-- Add the DeleteAttachmentFile table, which allows for attachment files to be deleted (garbage
-- collected) after all references to them have been removed from the database without worrying
-- about deleting them first and the database transaction failing.
--
-- Also add GarbageCollectionTable, a single-row table holding various information about when
-- GC has occurred and when it should occur next.
--
CREATE TABLE DeleteAttachmentFileTable (
id INTEGER PRIMARY KEY,
filename TEXT NOT NULL
);
CREATE TABLE GarbageCollectionTable (
id INTEGER PRIMARY KEY,
last_reap_time_t INTEGER DEFAULT NULL,
last_vacuum_time_t INTEGER DEFAULT NULL,
reaped_messages_since_last_vacuum INTEGER DEFAULT 0
);
-- Insert a single row with a well-known rowid and default values, this will be the row used
-- by the ImapDB.GC class.
INSERT INTO GarbageCollectionTable (id) VALUES (0);