diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 7b995def5..efb85ad60 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -760,7 +760,7 @@ void LocalStore::registerDrvOutput(const Realisation & info, CheckSigsFlag check void LocalStore::registerDrvOutput(const Realisation & info) { experimentalFeatureSettings.require(Xp::CaDerivations); - retrySQLite([&]() { + retrySQLite([&]() { auto state(_state.lock()); if (auto oldR = queryRealisation_(*state, info.id)) { if (info.isCompatibleWith(*oldR)) { @@ -817,7 +817,7 @@ void LocalStore::cacheDrvOutputMapping( const std::string & outputName, const StorePath & output) { - retrySQLite([&]() { + retrySQLite([&]() { state.stmts->AddDerivationOutput.use() (deriver) (outputName) @@ -880,7 +880,7 @@ uint64_t LocalStore::addValidPath(State & state, std::shared_ptr LocalStore::queryPathInfoUncached(const StorePath & path) { - return retrySQLite>([&]() { + return retrySQLite([&]() { auto state(_state.lock()); return queryPathInfoInternal(*state, path); }); @@ -968,7 +968,7 @@ bool LocalStore::isValidPath_(State & state, const StorePath & path) bool LocalStore::isValidPathUncached(const StorePath & path) { - return retrySQLite([&]() { + return retrySQLite([&]() { auto state(_state.lock()); return isValidPath_(*state, path); }); @@ -986,7 +986,7 @@ StorePathSet LocalStore::queryValidPaths(const StorePathSet & paths, SubstituteF StorePathSet LocalStore::queryAllValidPaths() { - return retrySQLite([&]() { + return retrySQLite([&]() { auto state(_state.lock()); auto use(state->stmts->QueryValidPaths.use()); StorePathSet res; @@ -1007,7 +1007,7 @@ void LocalStore::queryReferrers(State & state, const StorePath & path, StorePath void LocalStore::queryReferrers(const StorePath & path, StorePathSet & referrers) { - return retrySQLite([&]() { + return retrySQLite([&]() { auto state(_state.lock()); queryReferrers(*state, path, referrers); }); @@ -1016,7 +1016,7 @@ void LocalStore::queryReferrers(const StorePath & path, StorePathSet & referrers StorePathSet LocalStore::queryValidDerivers(const StorePath & path) { - return retrySQLite([&]() { + return retrySQLite([&]() { auto state(_state.lock()); auto useQueryValidDerivers(state->stmts->QueryValidDerivers.use()(printStorePath(path))); @@ -1033,7 +1033,7 @@ StorePathSet LocalStore::queryValidDerivers(const StorePath & path) std::map> LocalStore::queryStaticPartialDerivationOutputMap(const StorePath & path) { - return retrySQLite>>([&]() { + return retrySQLite([&]() { auto state(_state.lock()); std::map> outputs; uint64_t drvId; @@ -1053,7 +1053,7 @@ std::optional LocalStore::queryPathFromHashPart(const std::string & h Path prefix = config_.storeDir + "/" + hashPart; - return retrySQLite>([&]() -> std::optional { + return retrySQLite([&]() -> std::optional { auto state(_state.lock()); auto useQueryPathFromHashPart(state->stmts->QueryPathFromHashPart.use()(prefix)); @@ -1113,7 +1113,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos) registering operation. */ if (settings.syncBeforeRegistering) sync(); - return retrySQLite([&]() { + return retrySQLite([&]() { auto state(_state.lock()); SQLiteTxn txn(state->db); @@ -1504,7 +1504,7 @@ std::pair LocalStore::createTempDirInStore() void LocalStore::invalidatePathChecked(const StorePath & path) { - retrySQLite([&]() { + retrySQLite([&]() { auto state(_state.lock()); SQLiteTxn txn(state->db); @@ -1755,7 +1755,7 @@ void LocalStore::upgradeStore7() void LocalStore::addSignatures(const StorePath & storePath, const StringSet & sigs) { - retrySQLite([&]() { + retrySQLite([&]() { auto state(_state.lock()); SQLiteTxn txn(state->db); @@ -1852,11 +1852,10 @@ std::optional LocalStore::queryRealisation_( std::shared_ptr LocalStore::queryRealisationUncached(const DrvOutput & id) { - auto maybeRealisation - = retrySQLite>([&]() { - auto state(_state.lock()); - return queryRealisation_(*state, id); - }); + auto maybeRealisation = retrySQLite([&]() { + auto state(_state.lock()); + return queryRealisation_(*state, id); + }); if (maybeRealisation) return std::make_shared(maybeRealisation.value()); else diff --git a/lix/libstore/nar-info-disk-cache.cc b/lix/libstore/nar-info-disk-cache.cc index fe088dd7b..a02c6c602 100644 --- a/lix/libstore/nar-info-disk-cache.cc +++ b/lix/libstore/nar-info-disk-cache.cc @@ -136,7 +136,7 @@ public: )"); /* Periodically purge expired entries from the database. */ - retrySQLite([&]() { + retrySQLite([&]() { auto now = time(0); SQLiteStmt queryLastPurge(state->db, "select value from LastPurge"); @@ -191,7 +191,7 @@ private: public: int createCache(const std::string & uri, const Path & storeDir, bool wantMassQuery, int priority) override { - return retrySQLite([&]() { + return retrySQLite([&]() { auto state(_state.lock()); SQLiteTxn txn(state->db); @@ -224,7 +224,7 @@ public: std::optional upToDateCacheExists(const std::string & uri) override { - return retrySQLite>([&]() -> std::optional { + return retrySQLite([&]() -> std::optional { auto state(_state.lock()); auto cache(queryCacheRaw(*state, uri)); if (!cache) @@ -240,8 +240,7 @@ public: std::pair> lookupNarInfo( const std::string & uri, const std::string & hashPart) override { - return retrySQLite>>( - [&]() -> std::pair> { + return retrySQLite([&]() -> std::pair> { auto state(_state.lock()); auto & cache(getCache(*state, uri)); @@ -285,8 +284,7 @@ public: std::pair> lookupRealisation( const std::string & uri, const DrvOutput & id) override { - return retrySQLite>>( - [&]() -> std::pair> { + return retrySQLite([&]() -> std::pair> { auto state(_state.lock()); auto & cache(getCache(*state, uri)); @@ -318,7 +316,7 @@ public: const std::string & uri, const std::string & hashPart, std::shared_ptr info) override { - retrySQLite([&]() { + retrySQLite([&]() { auto state(_state.lock()); auto & cache(getCache(*state, uri)); @@ -358,7 +356,7 @@ public: const std::string & uri, const Realisation & realisation) override { - retrySQLite([&]() { + retrySQLite([&]() { auto state(_state.lock()); auto & cache(getCache(*state, uri)); @@ -376,7 +374,7 @@ public: const std::string & uri, const DrvOutput & id) override { - retrySQLite([&]() { + retrySQLite([&]() { auto state(_state.lock()); auto & cache(getCache(*state, uri)); diff --git a/lix/libstore/sqlite.cc b/lix/libstore/sqlite.cc index e053fc660..f3ccaf22f 100644 --- a/lix/libstore/sqlite.cc +++ b/lix/libstore/sqlite.cc @@ -98,7 +98,7 @@ void SQLite::isCache() void SQLite::exec(const std::string & stmt) { - retrySQLite([&]() { + retrySQLite([&]() { if (sqlite3_exec(db, stmt.c_str(), 0, 0, 0) != SQLITE_OK) SQLiteError::throw_(db, "executing SQLite statement '%s'", stmt); }); diff --git a/lix/libstore/sqlite.hh b/lix/libstore/sqlite.hh index 9cea9d906..01fb7e064 100644 --- a/lix/libstore/sqlite.hh +++ b/lix/libstore/sqlite.hh @@ -167,8 +167,8 @@ void handleSQLiteBusy(const SQLiteBusy & e, time_t & nextWarning); * Convenience function for retrying a SQLite transaction when the * database is busy. */ -template -T retrySQLite(F && fun) +template +auto retrySQLite(F && fun) { time_t nextWarning = time(0) + 1;