More sensible to have deleteGCPath in LocalStore.

This commit is contained in:
Ben Radford 2023-06-06 12:06:32 +01:00 committed by Ben Radford
parent a48acfd684
commit 8a9baa0a30
5 changed files with 14 additions and 14 deletions

View file

@ -97,13 +97,6 @@ struct GcStore : public virtual Store
* Perform a garbage collection.
*/
virtual void collectGarbage(const GCOptions & options, GCResults & results) = 0;
/**
* Called by `collectGarbage` to recursively delete a path.
* 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);
};
}

View file

@ -891,12 +891,6 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
}
void GcStore::deleteGCPath(const Path & path, uint64_t & bytesFreed)
{
deletePath(path, bytesFreed);
}
void LocalStore::autoGC(bool sync)
{
static auto fakeFreeSpaceFile = getEnv("_NIX_TEST_FREE_SPACE_FILE");

View file

@ -222,7 +222,7 @@ void LocalOverlayStore::deleteGCPath(const Path & path, uint64_t & bytesFreed)
return;
}
if (pathExists(toUpperPath({path.substr(mergedDir.length())}))) {
GcStore::deleteGCPath(path, bytesFreed);
LocalStore::deleteGCPath(path, bytesFreed);
}
}

View file

@ -457,6 +457,12 @@ AutoCloseFD LocalStore::openGCLock()
}
void LocalStore::deleteGCPath(const Path & path, uint64_t & bytesFreed)
{
deletePath(path, bytesFreed);
}
LocalStore::~LocalStore()
{
std::shared_future<void> future;

View file

@ -222,6 +222,13 @@ public:
void collectGarbage(const GCOptions & options, GCResults & results) override;
/**
* Called by `collectGarbage` to recursively delete a path.
* 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);
/**
* Optimise the disk space usage of the Nix store by hard-linking
* files with the same contents.