Skip deletion of lower paths for overlay store GC.

This commit is contained in:
Ben Radford 2023-05-24 11:26:33 +01:00 committed by Ben Radford
parent 98edbb9686
commit a48acfd684
2 changed files with 15 additions and 1 deletions

View file

@ -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<LocalOverlayStore, LocalOverlayStoreConfig> regLocalOverlayStore;
}

View file

@ -122,6 +122,8 @@ private:
void queryRealisationUncached(const DrvOutput&,
Callback<std::shared_ptr<const Realisation>> callback) noexcept override;
void deleteGCPath(const Path & path, uint64_t & bytesFreed) override;
};
}