Rename requireGcStore to GcStore::require

I should have done this to begin with. This will be nicer once more
Store sub-interfaces exist too, to illustrate the pattern.
This commit is contained in:
John Ericson 2022-03-08 17:45:19 +00:00
parent aee56e0f89
commit 073e134de6
7 changed files with 12 additions and 12 deletions

View file

@ -645,7 +645,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
Path path = absPath(readString(from));
logger->startWork();
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
gcStore.addIndirectRoot(path);
logger->stopWork();
@ -663,7 +663,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
case wopFindRoots: {
logger->startWork();
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
Roots roots = gcStore.findRoots(!trusted);
logger->stopWork();
@ -695,7 +695,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
logger->startWork();
if (options.ignoreLiveness)
throw Error("you are not allowed to ignore liveness");
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
gcStore.collectGarbage(options, results);
logger->stopWork();

View file

@ -2,7 +2,7 @@
namespace nix {
GcStore & requireGcStore(Store & store)
GcStore & GcStore::require(Store & store)
{
auto * gcStore = dynamic_cast<GcStore *>(&store);
if (!gcStore)

View file

@ -77,8 +77,8 @@ struct GcStore : public virtual Store
/* Perform a garbage collection. */
virtual void collectGarbage(const GCOptions & options, GCResults & results) = 0;
static GcStore & require(Store & store);
};
GcStore & requireGcStore(Store & store);
}

View file

@ -81,7 +81,7 @@ static int main_nix_collect_garbage(int argc, char * * argv)
// Run the actual garbage collector.
if (!dryRun) {
auto store = openStore();
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
options.action = GCOptions::gcDeleteDead;
GCResults results;
PrintFreed freed(true, results);

View file

@ -429,7 +429,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
store->computeFSClosure(
args, referrers, true, settings.gcKeepOutputs, settings.gcKeepDerivations);
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
Roots roots = gcStore.findRoots(false);
for (auto & [target, links] : roots)
if (referrers.find(target) != referrers.end())
@ -590,7 +590,7 @@ static void opGC(Strings opFlags, Strings opArgs)
if (!opArgs.empty()) throw UsageError("no arguments expected");
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
if (printRoots) {
Roots roots = gcStore.findRoots(false);
@ -629,7 +629,7 @@ static void opDelete(Strings opFlags, Strings opArgs)
for (auto & i : opArgs)
options.pathsToDelete.insert(store->followLinksToStorePath(i));
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
GCResults results;
PrintFreed freed(true, results);

View file

@ -33,7 +33,7 @@ struct CmdStoreDelete : StorePathsCommand
void run(ref<Store> store, std::vector<StorePath> && storePaths) override
{
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
for (auto & path : storePaths)
options.pathsToDelete.insert(path);

View file

@ -34,7 +34,7 @@ struct CmdStoreGC : StoreCommand, MixDryRun
void run(ref<Store> store) override
{
auto & gcStore = requireGcStore(*store);
auto & gcStore = GcStore::require(*store);
options.action = dryRun ? GCOptions::gcReturnDead : GCOptions::gcDeleteDead;
GCResults results;