From e6e495649cc1f324cd0a66cfaf3c4bdf21522e63 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 13 Sep 2012 14:33:41 -0400 Subject: Vacuum the SQLite DB after running the garbage collector --- src/libstore/gc.cc | 3 +++ src/libstore/local-store.cc | 7 +++++++ src/libstore/local-store.hh | 2 ++ 3 files changed, 12 insertions(+) diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index dc1de48ea..4a025a8fe 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -740,6 +740,9 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results) printMsg(lvlError, format("deleting unused links...")); removeUnusedLinks(state); } + + /* While we're at it, vacuum the database. */ + if (options.action == GCOptions::gcDeleteDead) vacuumDB(); } diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index bd63ce55d..793ec89d9 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1703,4 +1703,11 @@ void LocalStore::upgradeStore6() } +void LocalStore::vacuumDB() +{ + if (sqlite3_exec(db, "vacuum;", 0, 0, 0) != SQLITE_OK) + throwSQLiteError(db, "vacuuming SQLite database"); +} + + } diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index ba0582922..d2b13d6a9 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -195,6 +195,8 @@ public: void clearFailedPaths(const PathSet & paths); + void vacuumDB(); + private: Path schemaPath; -- cgit v1.2.3