Merge "libfetchers: fallback to memory SQLite if fs IO fails" into main
This commit is contained in:
commit
06c1375e52
1 changed files with 10 additions and 1 deletions
|
@ -34,7 +34,16 @@ struct CacheImpl : Cache
|
|||
auto state(_state.lock());
|
||||
|
||||
auto dbPath = getCacheDir() + "/nix/fetcher-cache-v1.sqlite";
|
||||
createDirs(dirOf(dbPath));
|
||||
// It would be silly to fail fetcher operations if e.g. the user has no
|
||||
// XDG_CACHE_HOME and their HOME directory doesn't exist.
|
||||
// We'll warn the user if that happens, but fallback to an in-memory
|
||||
// backend for the SQLite database.
|
||||
try {
|
||||
createDirs(dirOf(dbPath));
|
||||
} catch (SysError const & ex) {
|
||||
warn("ignoring error initializing Lix fetcher cache: %s", ex.what());
|
||||
dbPath = ":memory:";
|
||||
}
|
||||
|
||||
state->db = SQLite(dbPath);
|
||||
state->db.isCache();
|
||||
|
|
Loading…
Reference in a new issue