1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

Reuse deletion logic for optimiseStore and rename method.

This commit is contained in:
Ben Radford 2023-07-26 13:29:31 +01:00 committed by Ben Radford
parent 11c493f8fa
commit 33ebae75ca
5 changed files with 8 additions and 7 deletions

View file

@ -653,7 +653,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
results.paths.insert(path);
uint64_t bytesFreed;
deleteGCPath(realPath, bytesFreed);
deleteStorePath(realPath, bytesFreed);
results.bytesFreed += bytesFreed;

View file

@ -176,7 +176,7 @@ void LocalOverlayStore::registerValidPaths(const ValidPathInfos & infos)
}
void LocalOverlayStore::deleteGCPath(const Path & path, uint64_t & bytesFreed)
void LocalOverlayStore::deleteStorePath(const Path & path, uint64_t & bytesFreed)
{
auto mergedDir = realStoreDir.get() + "/";
if (path.substr(0, mergedDir.length()) != mergedDir) {
@ -198,7 +198,7 @@ void LocalOverlayStore::deleteGCPath(const Path & path, uint64_t & bytesFreed)
} else {
// Path does not exist in lower store.
// So we can delete via overlayfs and not need to remount.
LocalStore::deleteGCPath(path, bytesFreed);
LocalStore::deleteStorePath(path, bytesFreed);
}
}
}
@ -217,8 +217,9 @@ void LocalOverlayStore::optimiseStore()
for (auto & path : paths) {
if (lowerStore->isValidPath(path)) {
uint64_t bytesFreed = 0;
// Deduplicate store path
deletePath(toUpperPath(path));
deleteStorePath(Store::toRealPath(path), bytesFreed);
}
done++;
act.progress(done, paths.size());

View file

@ -118,7 +118,7 @@ private:
void queryRealisationUncached(const DrvOutput&,
Callback<std::shared_ptr<const Realisation>> callback) noexcept override;
void deleteGCPath(const Path & path, uint64_t & bytesFreed) override;
void deleteStorePath(const Path & path, uint64_t & bytesFreed) override;
void optimiseStore() override;

View file

@ -457,7 +457,7 @@ AutoCloseFD LocalStore::openGCLock()
}
void LocalStore::deleteGCPath(const Path & path, uint64_t & bytesFreed)
void LocalStore::deleteStorePath(const Path & path, uint64_t & bytesFreed)
{
deletePath(path, bytesFreed);
}

View file

@ -235,7 +235,7 @@ public:
* The default implementation simply calls `deletePath`, but it can be
* overridden by stores that wish to provide their own deletion behaviour.
*/
virtual void deleteGCPath(const Path & path, uint64_t & bytesFreed);
virtual void deleteStorePath(const Path & path, uint64_t & bytesFreed);
/**
* Optimise the disk space usage of the Nix store by hard-linking