From c3629be043a9839b27cc56ea80d6af002d4b320c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bellegarde?= Date: Sun, 15 Oct 2023 18:02:35 +0200 Subject: [PATCH] engine: Set database temp store Fix #1017 --- src/engine/imap-db/imap-db-database.vala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/engine/imap-db/imap-db-database.vala b/src/engine/imap-db/imap-db-database.vala index 45286f9b..a37ed024 100644 --- a/src/engine/imap-db/imap-db-database.vala +++ b/src/engine/imap-db/imap-db-database.vala @@ -617,6 +617,24 @@ private class Geary.ImapDB.Database : Geary.Db.VersionedDatabase { protected override void prepare_connection(Db.DatabaseConnection cx) throws GLib.Error { + + // SQLite might need more disk space than we have in /tmp + // So use XDG_CACHE_DIR instead + string tmp_path = "%s/geary/database".printf( + GLib.Environment.get_user_cache_dir() + ); + GLib.File tmp_directory = GLib.File.new_for_path(tmp_path); + try { + if (tmp_directory.query_exists() || tmp_directory.make_directory()) { + cx.exec( + "PRAGMA temp_store_directory = '%s'".printf(tmp_path) + ); + } + } catch (GLib.Error err) { + // Ignore error, will use /tmp as temp store + debug("couldn't set db temp dir to $XDG_CACHE_DIR: %s", err.message); + } + cx.set_busy_timeout_msec( Db.DatabaseConnection.RECOMMENDED_BUSY_TIMEOUT_MSEC );