diff --git a/src/libstore/local-overlay-store.cc b/src/libstore/local-overlay-store.cc index ab7af6aea..f42b37324 100644 --- a/src/libstore/local-overlay-store.cc +++ b/src/libstore/local-overlay-store.cc @@ -182,7 +182,7 @@ void LocalOverlayStore::addToStore(const ValidPathInfo & info, Source & source, LocalStore::addToStore(info, source, repair, checkSigs); if (lowerStore->isValidPath(info.path)) { // dedup stores - deletePath(toUpperPath(info.path)); + deletePath(toUpperPath(info.path)); // TODO: Investigate whether this can trigger 'stale file handle' errors. } } @@ -214,6 +214,18 @@ StorePath LocalOverlayStore::addTextToStore( } +void LocalOverlayStore::deleteGCPath(const Path & path, uint64_t & bytesFreed) +{ + auto mergedDir = realStoreDir.get() + "/"; + if (path.substr(0, mergedDir.length()) != mergedDir) { + warn("local-overlay: unexpected gc path '%s' ", path); + return; + } + if (pathExists(toUpperPath({path.substr(mergedDir.length())}))) { + GcStore::deleteGCPath(path, bytesFreed); + } +} + static RegisterStoreImplementation regLocalOverlayStore; } diff --git a/src/libstore/local-overlay-store.hh b/src/libstore/local-overlay-store.hh index 6f798c460..701024bfb 100644 --- a/src/libstore/local-overlay-store.hh +++ b/src/libstore/local-overlay-store.hh @@ -122,6 +122,8 @@ private: void queryRealisationUncached(const DrvOutput&, Callback> callback) noexcept override; + + void deleteGCPath(const Path & path, uint64_t & bytesFreed) override; }; }