aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-09-13 02:20:36 -0500
committerJP Dillingham <jp@dillingham.me>2026-09-13 02:20:36 -0500
commit6291f9e24cbd54b6c5ad6502101b4d668e51f57f (patch)
tree82ac590c13828558cd4e5af3b63b4b612944ce9e /src
parentfab938740106725aa8486eb4503cf91cfe8d81e2 (diff)
downloadslskd-6291f9e24cbd54b6c5ad6502101b4d668e51f57f.tar.gz
vacuum and checkpoint after backup
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Shares/SqliteShareRepository.cs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/slskd/Shares/SqliteShareRepository.cs b/src/slskd/Shares/SqliteShareRepository.cs
index a4be81b4..6d84308a 100644
--- a/src/slskd/Shares/SqliteShareRepository.cs
+++ b/src/slskd/Shares/SqliteShareRepository.cs
@@ -84,15 +84,23 @@ namespace slskd.Shares
/// <param name="repository">The destination repository.</param>
public void BackupTo(IShareRepository repository)
{
- using var sourceConn = GetConnection(ConnectionString);
- using var backupConn = GetConnection(repository.ConnectionString);
- sourceConn.BackupDatabase(backupConn);
+ using (var sourceConn = GetConnection(ConnectionString))
+ using (var backupConn = GetConnection(repository.ConnectionString))
+ {
+ sourceConn.BackupDatabase(backupConn);
+ }
+
+ using var backupRepository = new SqliteShareRepository(repository.ConnectionString);
Log.Debug("Vacuuming backup");
- using var cmd = new SqliteCommand("VACUUM", backupConn);
- cmd.ExecuteNonQuery();
+ backupRepository.Vacuum();
Log.Debug("Backup vacuumed successfully");
+ Log.Debug("Checkpointing backup");
+ backupRepository.Checkpoint();
+ Log.Debug("Backup checkpointed successfully");
+ }
+
/// <summary>
/// Checkpoints the current database, flushing the contents of the WAL (write ahead log) into the table(s).
/// </summary>