aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-18 22:09:22 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-18 22:11:26 +0000
commit15abb2aa2ba7de06a86e05511f81633616e17d87 (patch)
tree077cb0b6fe627e04aee10c93ed45f402996ebe70 /src/libstore
parentbbbf3602a323538b8da38f1a2c7ce136a20f74c6 (diff)
Revert the `enum struct` change
Not a regular git revert as there have been many merges and things.
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/binary-cache-store.cc12
-rw-r--r--src/libstore/build.cc112
-rw-r--r--src/libstore/builtins/fetchurl.cc2
-rw-r--r--src/libstore/daemon.cc23
-rw-r--r--src/libstore/derivations.cc8
-rw-r--r--src/libstore/export-import.cc10
-rw-r--r--src/libstore/filetransfer.cc6
-rw-r--r--src/libstore/gc.cc6
-rw-r--r--src/libstore/legacy-ssh-store.cc2
-rw-r--r--src/libstore/local-store.cc32
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/misc.cc2
-rw-r--r--src/libstore/nar-info-disk-cache.cc4
-rw-r--r--src/libstore/nar-info.cc8
-rw-r--r--src/libstore/optimise-store.cc16
-rw-r--r--src/libstore/path.cc2
-rw-r--r--src/libstore/references.cc4
-rw-r--r--src/libstore/remote-store.cc10
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/s3-binary-cache-store.cc4
-rw-r--r--src/libstore/ssh.cc4
-rw-r--r--src/libstore/store-api.cc34
-rw-r--r--src/libstore/store-api.hh8
23 files changed, 142 insertions, 171 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index fbc466e2e..9f52ddafa 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -137,7 +137,7 @@ void BinaryCacheStore::addToStore(const ValidPathInfo & info, Source & narSource
auto narInfo = make_ref<NarInfo>(info);
narInfo->narSize = nar->size();
- narInfo->narHash = hashString(HashType::SHA256, *nar);
+ narInfo->narHash = hashString(htSHA256, *nar);
if (info.narHash && info.narHash != narInfo->narHash)
throw Error("refusing to copy corrupted path '%1%' to binary cache", printStorePath(info.path));
@@ -172,16 +172,16 @@ void BinaryCacheStore::addToStore(const ValidPathInfo & info, Source & narSource
auto now1 = std::chrono::steady_clock::now();
auto narCompressed = compress(compression, *nar, parallelCompression);
auto now2 = std::chrono::steady_clock::now();
- narInfo->fileHash = hashString(HashType::SHA256, *narCompressed);
+ narInfo->fileHash = hashString(htSHA256, *narCompressed);
narInfo->fileSize = narCompressed->size();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
- printMsg(Verbosity::Talkative, "copying path '%1%' (%2% bytes, compressed %3$.1f%% in %4% ms) to binary cache",
+ printMsg(lvlTalkative, "copying path '%1%' (%2% bytes, compressed %3$.1f%% in %4% ms) to binary cache",
printStorePath(narInfo->path), narInfo->narSize,
((1.0 - (double) narCompressed->size() / nar->size()) * 100.0),
duration);
- narInfo->url = "nar/" + narInfo->fileHash.to_string(Base::Base32, false) + ".nar"
+ narInfo->url = "nar/" + narInfo->fileHash.to_string(Base32, false) + ".nar"
+ (compression == "xz" ? ".xz" :
compression == "bzip2" ? ".bz2" :
compression == "br" ? ".br" :
@@ -209,7 +209,7 @@ void BinaryCacheStore::addToStore(const ValidPathInfo & info, Source & narSource
// to a GC'ed file, so overwriting might be useful...
if (fileExists(key)) return;
- printMsg(Verbosity::Talkative, "creating debuginfo link from '%s' to '%s'", key, target);
+ printMsg(lvlTalkative, "creating debuginfo link from '%s' to '%s'", key, target);
upsertFile(key, json.dump(), "application/json");
};
@@ -302,7 +302,7 @@ void BinaryCacheStore::queryPathInfoUncached(const StorePath & storePath,
{
auto uri = getUri();
auto storePathS = printStorePath(storePath);
- auto act = std::make_shared<Activity>(*logger, Verbosity::Talkative, ActivityType::QueryPathInfo,
+ auto act = std::make_shared<Activity>(*logger, lvlTalkative, actQueryPathInfo,
fmt("querying info about '%s' on '%s'", storePathS, uri), Logger::Fields{storePathS, uri});
PushActivity pact(act->id);
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index dda84d536..47a153bbc 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -106,13 +106,7 @@ typedef std::map<StorePath, WeakGoalPtr> WeakGoalMap;
struct Goal : public std::enable_shared_from_this<Goal>
{
- enum struct ExitCode {
- Busy,
- Success,
- Failed,
- NoSubstituters,
- IncompleteClosure,
- };
+ typedef enum {ecBusy, ecSuccess, ecFailed, ecNoSubstituters, ecIncompleteClosure} ExitCode;
/* Backlink to the worker. */
Worker & worker;
@@ -147,7 +141,7 @@ struct Goal : public std::enable_shared_from_this<Goal>
Goal(Worker & worker) : worker(worker)
{
nrFailed = nrNoSubstituters = nrIncompleteClosure = 0;
- exitCode = ExitCode::Busy;
+ exitCode = ecBusy;
}
virtual ~Goal()
@@ -359,8 +353,8 @@ public:
{
actDerivations.progress(doneBuilds, expectedBuilds + doneBuilds, runningBuilds, failedBuilds);
actSubstitutions.progress(doneSubstitutions, expectedSubstitutions + doneSubstitutions, runningSubstitutions, failedSubstitutions);
- act.setExpected(ActivityType::Download, expectedDownloadSize + doneDownloadSize);
- act.setExpected(ActivityType::CopyPath, expectedNarSize + doneNarSize);
+ act.setExpected(actFileTransfer, expectedDownloadSize + doneDownloadSize);
+ act.setExpected(actCopyPath, expectedNarSize + doneNarSize);
}
};
@@ -392,13 +386,13 @@ void Goal::waiteeDone(GoalPtr waitee, ExitCode result)
trace(fmt("waitee '%s' done; %d left", waitee->name, waitees.size()));
- if (result == ExitCode::Failed || result == ExitCode::NoSubstituters || result == ExitCode::IncompleteClosure) ++nrFailed;
+ if (result == ecFailed || result == ecNoSubstituters || result == ecIncompleteClosure) ++nrFailed;
- if (result == ExitCode::NoSubstituters) ++nrNoSubstituters;
+ if (result == ecNoSubstituters) ++nrNoSubstituters;
- if (result == ExitCode::IncompleteClosure) ++nrIncompleteClosure;
+ if (result == ecIncompleteClosure) ++nrIncompleteClosure;
- if (waitees.empty() || (result == ExitCode::Failed && !settings.keepGoing)) {
+ if (waitees.empty() || (result == ecFailed && !settings.keepGoing)) {
/* If we failed and keepGoing is not set, we remove all
remaining waitees. */
@@ -418,8 +412,8 @@ void Goal::waiteeDone(GoalPtr waitee, ExitCode result)
void Goal::amDone(ExitCode result, std::optional<Error> ex)
{
trace("done");
- assert(exitCode == ExitCode::Busy);
- assert(result == ExitCode::Success || result == ExitCode::Failed || result == ExitCode::NoSubstituters || result == ExitCode::IncompleteClosure);
+ assert(exitCode == ecBusy);
+ assert(result == ecSuccess || result == ecFailed || result == ecNoSubstituters || result == ecIncompleteClosure);
exitCode = result;
if (ex) {
@@ -684,7 +678,7 @@ HookInstance::HookInstance()
Strings args = {
std::string(baseNameOf(settings.buildHook.get())),
- std::to_string((uint64_t)verbosity),
+ std::to_string(verbosity),
};
execv(settings.buildHook.get().c_str(), stringsToCharPtrs(args).data());
@@ -1422,7 +1416,7 @@ void DerivationGoal::started() {
"building '%s'", worker.store.printStorePath(drvPath), curRound, nrRounds);
fmt("building '%s'", worker.store.printStorePath(drvPath));
if (hook) msg += fmt(" on '%s'", machineName);
- act = std::make_unique<Activity>(*logger, Verbosity::Info, ActivityType::Build, msg,
+ act = std::make_unique<Activity>(*logger, lvlInfo, actBuild, msg,
Logger::Fields{worker.store.printStorePath(drvPath), hook ? machineName : "", curRound, nrRounds});
mcRunningBuilds = std::make_unique<MaintainCount<uint64_t>>(worker.runningBuilds);
worker.updateProgress();
@@ -1443,7 +1437,7 @@ void DerivationGoal::tryToBuild()
if (!outputLocks.lockPaths(lockFiles, "", false)) {
if (!actLock)
- actLock = std::make_unique<Activity>(*logger, Verbosity::Warn, ActivityType::BuildWaiting,
+ actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
fmt("waiting for lock on %s", yellowtxt(showPaths(lockFiles))));
worker.waitForAWhile(shared_from_this());
return;
@@ -1483,20 +1477,6 @@ void DerivationGoal::tryToBuild()
supported for local builds. */
bool buildLocally = buildMode != bmNormal || parsedDrv->willBuildLocally();
- auto started = [&]() {
- auto msg = fmt(
- buildMode == bmRepair ? "repairing outputs of '%s'" :
- buildMode == bmCheck ? "checking outputs of '%s'" :
- nrRounds > 1 ? "building '%s' (round %d/%d)" :
- "building '%s'", worker.store.printStorePath(drvPath), curRound, nrRounds);
- fmt("building '%s'", worker.store.printStorePath(drvPath));
- if (hook) msg += fmt(" on '%s'", machineName);
- act = std::make_unique<Activity>(*logger, Verbosity::Info, ActivityType::Build, msg,
- Logger::Fields{worker.store.printStorePath(drvPath), hook ? machineName : "", curRound, nrRounds});
- mcRunningBuilds = std::make_unique<MaintainCount<uint64_t>>(worker.runningBuilds);
- worker.updateProgress();
- };
-
/* Is the build hook willing to accept this job? */
if (!buildLocally) {
switch (tryBuildHook()) {
@@ -1512,7 +1492,7 @@ void DerivationGoal::tryToBuild()
/* Not now; wait until at least one child finishes or
the wake-up timeout expires. */
if (!actLock)
- actLock = std::make_unique<Activity>(*logger, Verbosity::Warn, ActivityType::BuildWaiting,
+ actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
fmt("waiting for a machine to build '%s'", yellowtxt(worker.store.printStorePath(drvPath))));
worker.waitForAWhile(shared_from_this());
outputLocks.unlock();
@@ -1553,7 +1533,7 @@ void DerivationGoal::tryLocalBuild() {
buildUser->kill();
} else {
if (!actLock)
- actLock = std::make_unique<Activity>(*logger, Verbosity::Warn, ActivityType::BuildWaiting,
+ actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
fmt("waiting for UID to build '%s'", yellowtxt(worker.store.printStorePath(drvPath))));
worker.waitForAWhile(shared_from_this());
return;
@@ -1708,7 +1688,7 @@ void DerivationGoal::buildDone()
registerOutputs();
if (settings.postBuildHook != "") {
- Activity act(*logger, Verbosity::Info, ActivityType::PostBuildHook,
+ Activity act(*logger, lvlInfo, actPostBuildHook,
fmt("running post-build-hook '%s'", settings.postBuildHook),
Logger::Fields{worker.store.printStorePath(drvPath)});
PushActivity pact(act.id);
@@ -1740,7 +1720,7 @@ void DerivationGoal::buildDone()
}
void flushLine() {
- act.result(ResultType::PostBuildLogLine, currentLine);
+ act.result(resPostBuildLogLine, currentLine);
currentLine.clear();
}
@@ -2144,7 +2124,7 @@ void DerivationGoal::startBuilder()
/* Clean up the chroot directory automatically. */
autoDelChroot = std::make_shared<AutoDelete>(chrootRootDir);
- printMsg(Verbosity::Chatty, format("setting up chroot environment in '%1%'") % chrootRootDir);
+ printMsg(lvlChatty, format("setting up chroot environment in '%1%'") % chrootRootDir);
if (mkdir(chrootRootDir.c_str(), 0750) == -1)
throw SysError("cannot create '%1%'", chrootRootDir);
@@ -2253,7 +2233,7 @@ void DerivationGoal::startBuilder()
}
if (useChroot && settings.preBuildHook != "" && dynamic_cast<Derivation *>(drv.get())) {
- printMsg(Verbosity::Chatty, format("executing pre-build hook '%1%'")
+ printMsg(lvlChatty, format("executing pre-build hook '%1%'")
% settings.preBuildHook);
auto args = useChroot ? Strings({worker.store.printStorePath(drvPath), chrootRootDir}) :
Strings({ worker.store.printStorePath(drvPath) });
@@ -2294,7 +2274,7 @@ void DerivationGoal::startBuilder()
startDaemon();
/* Run the builder. */
- printMsg(Verbosity::Chatty, "executing builder '%1%'", drv->builder);
+ printMsg(lvlChatty, "executing builder '%1%'", drv->builder);
/* Create the log file. */
Path logFile = openLogFile();
@@ -2530,8 +2510,8 @@ void DerivationGoal::initTmpDir() {
if (passAsFile.find(i.first) == passAsFile.end()) {
env[i.first] = i.second;
} else {
- auto hash = hashString(HashType::SHA256, i.first);
- string fn = ".attr-" + hash.to_string(Base::Base32, false);
+ auto hash = hashString(htSHA256, i.first);
+ string fn = ".attr-" + hash.to_string(Base32, false);
Path p = tmpDir + "/" + fn;
writeFile(p, rewriteStrings(i.second, inputRewrites));
chownToBuilder(p);
@@ -2777,7 +2757,7 @@ struct RestrictedStore : public LocalFSStore
{ throw Error("queryPathFromHashPart"); }
StorePath addToStore(const string & name, const Path & srcPath,
- FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = HashType::SHA256,
+ FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = htSHA256,
PathFilter & filter = defaultPathFilter, RepairFlag repair = NoRepair) override
{ throw Error("addToStore"); }
@@ -2790,7 +2770,7 @@ struct RestrictedStore : public LocalFSStore
}
StorePath addToStoreFromDump(const string & dump, const string & name,
- FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = HashType::SHA256, RepairFlag repair = NoRepair) override
+ FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = htSHA256, RepairFlag repair = NoRepair) override
{
auto path = next->addToStoreFromDump(dump, name, method, hashAlgo, repair);
goal.addDependency(path);
@@ -3765,7 +3745,7 @@ void DerivationGoal::registerOutputs()
worker.hashMismatch = true;
delayedException = std::make_exception_ptr(
BuildError("hash mismatch in fixed-output derivation '%s':\n wanted: %s\n got: %s",
- worker.store.printStorePath(dest), h.to_string(Base::SRI, true), h2.to_string(Base::SRI, true)));
+ worker.store.printStorePath(dest), h.to_string(SRI, true), h2.to_string(SRI, true)));
Path actualDest = worker.store.Store::toRealPath(dest);
@@ -4209,7 +4189,7 @@ void DerivationGoal::flushLine()
logTail.push_back(currentLogLine);
if (logTail.size() > settings.logLines) logTail.pop_front();
- act->result(ResultType::BuildLogLine, currentLogLine);
+ act->result(resBuildLogLine, currentLogLine);
}
currentLogLine = "";
@@ -4236,7 +4216,7 @@ void DerivationGoal::addHashRewrite(const StorePath & path)
auto h1 = std::string(((std::string_view) path.to_string()).substr(0, 32));
auto p = worker.store.makeStorePath(
"rewrite:" + std::string(drvPath.to_string()) + ":" + std::string(path.to_string()),
- Hash(HashType::SHA256), path.name());
+ Hash(htSHA256), path.name());
auto h2 = std::string(((std::string_view) p.to_string()).substr(0, 32));
deletePath(worker.store.printStorePath(p));
inputRewrites[h1] = h2;
@@ -4250,7 +4230,7 @@ void DerivationGoal::done(BuildResult::Status status, std::optional<Error> ex)
result.status = status;
if (ex)
result.errorMsg = ex->what();
- amDone(result.success() ? ExitCode::Success : ExitCode::Failed, ex);
+ amDone(result.success() ? ecSuccess : ecFailed, ex);
if (result.status == BuildResult::TimedOut)
worker.timedOut = true;
if (result.status == BuildResult::PermanentFailure)
@@ -4386,7 +4366,7 @@ void SubstitutionGoal::init()
/* If the path already exists we're done. */
if (!repair && worker.store.isValidPath(storePath)) {
- amDone(ExitCode::Success);
+ amDone(ecSuccess);
return;
}
@@ -4411,7 +4391,7 @@ void SubstitutionGoal::tryNext()
/* Hack: don't indicate failure if there were no substituters.
In that case the calling derivation should just do a
build. */
- amDone(substituterFailed ? ExitCode::Failed : ExitCode::NoSubstituters);
+ amDone(substituterFailed ? ecFailed : ecNoSubstituters);
if (substituterFailed) {
worker.failedSubstitutions++;
@@ -4497,7 +4477,7 @@ void SubstitutionGoal::referencesValid()
if (nrFailed > 0) {
debug("some references of path '%s' could not be realised", worker.store.printStorePath(storePath));
- amDone(nrNoSubstituters > 0 || nrIncompleteClosure > 0 ? ExitCode::IncompleteClosure : ExitCode::Failed);
+ amDone(nrNoSubstituters > 0 || nrIncompleteClosure > 0 ? ecIncompleteClosure : ecFailed);
return;
}
@@ -4535,7 +4515,7 @@ void SubstitutionGoal::tryToRun()
/* Wake up the worker loop when we're done. */
Finally updateStats([this]() { outPipe.writeSide = -1; });
- Activity act(*logger, ActivityType::Substitute, Logger::Fields{worker.store.printStorePath(storePath), sub->getUri()});
+ Activity act(*logger, actSubstitute, Logger::Fields{worker.store.printStorePath(storePath), sub->getUri()});
PushActivity pact(act.id);
copyStorePath(ref<Store>(sub), ref<Store>(worker.store.shared_from_this()),
@@ -4584,7 +4564,7 @@ void SubstitutionGoal::finished()
worker.markContentsGood(storePath);
- printMsg(Verbosity::Chatty, "substitution of path '%s' succeeded", worker.store.printStorePath(storePath));
+ printMsg(lvlChatty, "substitution of path '%s' succeeded", worker.store.printStorePath(storePath));
maintainRunningSubstitutions.reset();
@@ -4602,7 +4582,7 @@ void SubstitutionGoal::finished()
worker.updateProgress();
- amDone(ExitCode::Success);
+ amDone(ecSuccess);
}
@@ -4620,9 +4600,9 @@ void SubstitutionGoal::handleEOF(int fd)
Worker::Worker(LocalStore & store)
- : act(*logger, ActivityType::Realise)
- , actDerivations(*logger, ActivityType::Builds)
- , actSubstitutions(*logger, ActivityType::CopyPaths)
+ : act(*logger, actRealise)
+ , actDerivations(*logger, actBuilds)
+ , actSubstitutions(*logger, actCopyPaths)
, store(store)
{
/* Debugging: prevent recursive workers. */
@@ -4706,7 +4686,7 @@ void Worker::removeGoal(GoalPtr goal)
topGoals.erase(goal);
/* If a top-level goal failed, then kill all other goals
(unless keepGoing was set). */
- if (goal->exitCode == Goal::ExitCode::Failed && !settings.keepGoing)
+ if (goal->exitCode == Goal::ecFailed && !settings.keepGoing)
topGoals.clear();
}
@@ -4849,7 +4829,7 @@ void Worker::run(const Goals & _topGoals)
void Worker::waitForInput()
{
- printMsg(Verbosity::Vomit, "waiting for children");
+ printMsg(lvlVomit, "waiting for children");
/* Process output from the file descriptors attached to the
children, namely log output and output path creation commands.
@@ -4939,7 +4919,7 @@ void Worker::waitForInput()
if (errno != EINTR)
throw SysError("%s: read failed", goal->getName());
} else {
- printMsg(Verbosity::Vomit, "%1%: read %2% bytes",
+ printMsg(lvlVomit, "%1%: read %2% bytes",
goal->getName(), rd);
string data((char *) buffer.data(), rd);
j->lastOutput = after;
@@ -4948,7 +4928,7 @@ void Worker::waitForInput()
}
}
- if (goal->exitCode == Goal::ExitCode::Busy &&
+ if (goal->exitCode == Goal::ecBusy &&
0 != settings.maxSilentTime &&
j->respectTimeouts &&
after - j->lastOutput >= std::chrono::seconds(settings.maxSilentTime))
@@ -4958,7 +4938,7 @@ void Worker::waitForInput()
goal->getName(), settings.maxSilentTime));
}
- else if (goal->exitCode == Goal::ExitCode::Busy &&
+ else if (goal->exitCode == Goal::ecBusy &&
0 != settings.buildTimeout &&
j->respectTimeouts &&
after - j->timeStarted >= std::chrono::seconds(settings.buildTimeout))
@@ -5019,7 +4999,7 @@ bool Worker::pathContentsGood(const StorePath & path)
res = false;
else {
HashResult current = hashPath(*info->narHash.type, store.printStorePath(path));
- Hash nullHash(HashType::SHA256);
+ Hash nullHash(htSHA256);
res = info->narHash == nullHash || info->narHash == current.first;
}
pathContentsGoodCache.insert_or_assign(path, res);
@@ -5079,7 +5059,7 @@ void LocalStore::buildPaths(const std::vector<StorePathWithOutputs> & drvPaths,
else
ex = i->ex;
}
- if (i->exitCode != Goal::ExitCode::Success) {
+ if (i->exitCode != Goal::ecSuccess) {
DerivationGoal * i2 = dynamic_cast<DerivationGoal *>(i.get());
if (i2) failed.insert(i2->getDrvPath());
else failed.insert(dynamic_cast<SubstitutionGoal *>(i.get())->getStorePath());
@@ -5128,7 +5108,7 @@ void LocalStore::ensurePath(const StorePath & path)
worker.run(goals);
- if (goal->exitCode != Goal::ExitCode::Success) {
+ if (goal->exitCode != Goal::ecSuccess) {
if (goal->ex) {
goal->ex->status = worker.exitStatus();
throw *goal->ex;
@@ -5146,7 +5126,7 @@ void LocalStore::repairPath(const StorePath & path)
worker.run(goals);
- if (goal->exitCode != Goal::ExitCode::Success) {
+ if (goal->exitCode != Goal::ecSuccess) {
/* Since substituting the path didn't work, if we have a valid
deriver, then rebuild the deriver. */
auto info = queryPathInfo(path);
diff --git a/src/libstore/builtins/fetchurl.cc b/src/libstore/builtins/fetchurl.cc
index 3a8d30e80..1cfe4a46a 100644
--- a/src/libstore/builtins/fetchurl.cc
+++ b/src/libstore/builtins/fetchurl.cc
@@ -65,7 +65,7 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
auto ht = parseHashTypeOpt(getAttr("outputHashAlgo"));
auto h = Hash(getAttr("outputHash"), ht);
- fetch(hashedMirror + printHashType(*h.type) + "/" + h.to_string(Base::Base16, false));
+ fetch(hashedMirror + printHashType(*h.type) + "/" + h.to_string(Base16, false));
return;
} catch (Error & e) {
debug(e.what());
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc
index 356479f5a..e370e278c 100644
--- a/src/libstore/daemon.cc
+++ b/src/libstore/daemon.cc
@@ -126,13 +126,7 @@ struct TunnelLogger : public Logger
}
StringSink buf;
- buf << STDERR_START_ACTIVITY
- << act
- << (uint64_t) lvl
- << (uint64_t) type
- << s
- << fields
- << parent;
+ buf << STDERR_START_ACTIVITY << act << lvl << type << s << fields << parent;
enqueueMsg(*buf.s);
}
@@ -148,10 +142,7 @@ struct TunnelLogger : public Logger
{
if (GET_PROTOCOL_MINOR(clientVersion) < 20) return;
StringSink buf;
- buf << STDERR_RESULT
- << act
- << (uint64_t) type
- << fields;
+ buf << STDERR_RESULT << act << type << fields;
enqueueMsg(*buf.s);
}
};
@@ -323,7 +314,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
logger->startWork();
auto hash = store->queryPathInfo(path)->narHash;
logger->stopWork();
- to << hash.to_string(Base::Base16, false);
+ to << hash.to_string(Base16, false);
break;
}
@@ -572,7 +563,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
clientSettings.maxBuildJobs = readInt(from);
clientSettings.maxSilentTime = readInt(from);
readInt(from); // obsolete useBuildHook
- clientSettings.verboseBuild = Verbosity::Error == (Verbosity) readInt(from);
+ clientSettings.verboseBuild = lvlError == (Verbosity) readInt(from);
readInt(from); // obsolete logType
readInt(from); // obsolete printBuildTrace
clientSettings.buildCores = readInt(from);
@@ -655,7 +646,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
if (GET_PROTOCOL_MINOR(clientVersion) >= 17)
to << 1;
to << (info->deriver ? store->printStorePath(*info->deriver) : "")
- << info->narHash.to_string(Base::Base16, false);
+ << info->narHash.to_string(Base16, false);
writeStorePaths(*store, to, info->references);
to << info->registrationTime << info->narSize;
if (GET_PROTOCOL_MINOR(clientVersion) >= 16) {
@@ -715,7 +706,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
auto deriver = readString(from);
if (deriver != "")
info.deriver = store->parseStorePath(deriver);
- info.narHash = Hash(readString(from), HashType::SHA256);
+ info.narHash = Hash(readString(from), htSHA256);
info.references = readStorePaths<StorePathSet>(*store, from);
from >> info.registrationTime >> info.narSize >> info.ultimate;
info.sigs = readStrings<StringSet>(from);
@@ -798,7 +789,7 @@ void processConnection(
Finally finally([&]() {
_isInterrupted = false;
- prevLogger->log(Verbosity::Debug, fmt("%d operations", opCount));
+ prevLogger->log(lvlDebug, fmt("%d operations", opCount));
});
if (GET_PROTOCOL_MINOR(clientVersion) >= 14 && readInt(from)) {
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index 5dc8605df..5882a7411 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -350,7 +350,7 @@ Hash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOutput
/* Return a fixed hash for fixed-output derivations. */
if (drv.isFixedOutput()) {
DerivationOutputs::const_iterator i = drv.outputs.begin();
- return hashString(HashType::SHA256, "fixed:out:"
+ return hashString(htSHA256, "fixed:out:"
+ i->second.hashAlgo + ":"
+ i->second.hash + ":"
+ store.printStorePath(i->second.path));
@@ -366,10 +366,10 @@ Hash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOutput
h = drvHashes.insert_or_assign(i.first, hashDerivationModulo(store,
store.readDerivation(i.first), false)).first;
}
- inputs2.insert_or_assign(h->second.to_string(Base::Base16, false), i.second);
+ inputs2.insert_or_assign(h->second.to_string(Base16, false), i.second);
}
- return hashString(HashType::SHA256, drv.unparse(store, maskOutputs, &inputs2));
+ return hashString(htSHA256, drv.unparse(store, maskOutputs, &inputs2));
}
@@ -452,7 +452,7 @@ void writeDerivation(Sink & out, const Store & store, const BasicDerivation & dr
std::string hashPlaceholder(const std::string & outputName)
{
// FIXME: memoize?
- return "/" + hashString(HashType::SHA256, "nix-output:" + outputName).to_string(Base::Base32, false);
+ return "/" + hashString(htSHA256, "nix-output:" + outputName).to_string(Base32, false);
}
diff --git a/src/libstore/export-import.cc b/src/libstore/export-import.cc
index f948d0f9a..57b7e9590 100644
--- a/src/libstore/export-import.cc
+++ b/src/libstore/export-import.cc
@@ -11,7 +11,7 @@ struct HashAndWriteSink : Sink
{
Sink & writeSink;
HashSink hashSink;
- HashAndWriteSink(Sink & writeSink) : writeSink(writeSink), hashSink(HashType::SHA256)
+ HashAndWriteSink(Sink & writeSink) : writeSink(writeSink), hashSink(htSHA256)
{
}
virtual void operator () (const unsigned char * data, size_t len)
@@ -34,7 +34,7 @@ void Store::exportPaths(const StorePathSet & paths, Sink & sink)
//logger->incExpected(doneLabel, sorted.size());
for (auto & path : sorted) {
- //Activity act(*logger, Verbosity::Info, format("exporting path '%s'") % path);
+ //Activity act(*logger, lvlInfo, format("exporting path '%s'") % path);
sink << 1;
exportPath(path, sink);
//logger->incProgress(doneLabel);
@@ -57,7 +57,7 @@ void Store::exportPath(const StorePath & path, Sink & sink)
Hash hash = hashAndWriteSink.currentHash();
if (hash != info->narHash && info->narHash != Hash(*info->narHash.type))
throw Error("hash of path '%s' has changed from '%s' to '%s'!",
- printStorePath(path), info->narHash.to_string(Base::Base32, true), hash.to_string(Base::Base32, true));
+ printStorePath(path), info->narHash.to_string(Base32, true), hash.to_string(Base32, true));
hashAndWriteSink
<< exportMagic
@@ -86,7 +86,7 @@ StorePaths Store::importPaths(Source & source, std::shared_ptr<FSAccessor> acces
ValidPathInfo info(parseStorePath(readString(source)));
- //Activity act(*logger, Verbosity::Info, format("importing path '%s'") % info.path);
+ //Activity act(*logger, lvlInfo, format("importing path '%s'") % info.path);
info.references = readStorePaths<StorePathSet>(*this, source);
@@ -94,7 +94,7 @@ StorePaths Store::importPaths(Source & source, std::shared_ptr<FSAccessor> acces
if (deriver != "")
info.deriver = parseStorePath(deriver);
- info.narHash = hashString(HashType::SHA256, *tee.source.data);
+ info.narHash = hashString(htSHA256, *tee.source.data);
info.narSize = tee.source.data->size();
// Ignore optional legacy signature.
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index f27d0c647..531b85af8 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -89,7 +89,7 @@ struct curlFileTransfer : public FileTransfer
Callback<FileTransferResult> && callback)
: fileTransfer(fileTransfer)
, request(request)
- , act(*logger, Verbosity::Talkative, ActivityType::Download,
+ , act(*logger, lvlTalkative, actFileTransfer,
fmt(request.data ? "uploading '%s'" : "downloading '%s'", request.uri),
{request.uri}, request.parentAct)
, callback(std::move(callback))
@@ -174,7 +174,7 @@ struct curlFileTransfer : public FileTransfer
{
size_t realSize = size * nmemb;
std::string line((char *) contents, realSize);
- printMsg(Verbosity::Vomit, format("got header for '%s': %s") % request.uri % trim(line));
+ printMsg(lvlVomit, format("got header for '%s': %s") % request.uri % trim(line));
if (line.compare(0, 5, "HTTP/") == 0) { // new response starts
result.etag = "";
auto ss = tokenizeString<vector<string>>(line, " ");
@@ -257,7 +257,7 @@ struct curlFileTransfer : public FileTransfer
curl_easy_reset(req);
- if (verbosity >= Verbosity::Vomit) {
+ if (verbosity >= lvlVomit) {
curl_easy_setopt(req, CURLOPT_VERBOSE, 1);
curl_easy_setopt(req, CURLOPT_DEBUGFUNCTION, TransferItem::debugCallback);
}
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index 31565c78e..57fb20845 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -78,7 +78,7 @@ void LocalStore::syncWithGC()
void LocalStore::addIndirectRoot(const Path & path)
{
- string hash = hashString(HashType::SHA1, path).to_string(Base::Base32, false);
+ string hash = hashString(htSHA1, path).to_string(Base32, false);
Path realRoot = canonPath((format("%1%/%2%/auto/%3%")
% stateDir % gcRootsDir % hash).str());
makeSymlink(realRoot, path);
@@ -639,7 +639,7 @@ void LocalStore::tryToDelete(GCState & state, const Path & path)
auto realPath = realStoreDir + "/" + std::string(baseNameOf(path));
if (realPath == linksDir || realPath == trashDir) return;
- //Activity act(*logger, Verbosity::Debug, format("considering whether to delete '%1%'") % path);
+ //Activity act(*logger, lvlDebug, format("considering whether to delete '%1%'") % path);
auto storePath = maybeParseStorePath(path);
@@ -704,7 +704,7 @@ void LocalStore::removeUnusedLinks(const GCState & state)
continue;
}
- printMsg(Verbosity::Talkative, format("deleting unused link '%1%'") % path);
+ printMsg(lvlTalkative, format("deleting unused link '%1%'") % path);
if (unlink(path.c_str()) == -1)
throw SysError("deleting '%1%'", path);
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index a7bcc0031..45c70fad6 100644
--- a/src/libstore/legacy-ssh-store.cc
+++ b/src/libstore/legacy-ssh-store.cc
@@ -139,7 +139,7 @@ struct LegacySSHStore : public Store
<< cmdAddToStoreNar
<< printStorePath(info.path)
<< (info.deriver ? printStorePath(*info.deriver) : "")
- << info.narHash.to_string(Base::Base16, false);
+ << info.narHash.to_string(Base16, false);
writeStorePaths(*this, conn->to, info.references);
conn->to
<< info.registrationTime
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 60ad138a3..df4edbbca 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -584,7 +584,7 @@ uint64_t LocalStore::addValidPath(State & state,
state.stmtRegisterValidPath.use()
(printStorePath(info.path))
- (info.narHash.to_string(Base::Base16, true))
+ (info.narHash.to_string(Base16, true))
(info.registrationTime == 0 ? time(0) : info.registrationTime)
(info.deriver ? printStorePath(*info.deriver) : "", (bool) info.deriver)
(info.narSize, info.narSize != 0)
@@ -684,7 +684,7 @@ void LocalStore::updatePathInfo(State & state, const ValidPathInfo & info)
{
state.stmtUpdatePathInfo.use()
(info.narSize, info.narSize != 0)
- (info.narHash.to_string(Base::Base16, true))
+ (info.narHash.to_string(Base16, true))
(info.ultimate ? 1 : 0, info.ultimate)
(concatStringsSep(" ", info.sigs), !info.sigs.empty())
(info.ca, !info.ca.empty())
@@ -895,7 +895,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
StorePathSet paths;
for (auto & i : infos) {
- assert(i.narHash.type == HashType::SHA256);
+ assert(i.narHash.type == htSHA256);
if (isValidPath_(*state, i.path))
updatePathInfo(*state, i);
else
@@ -992,9 +992,9 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
of the NAR. */
std::unique_ptr<AbstractHashSink> hashSink;
if (info.ca == "" || !info.references.count(info.path))
- hashSink = std::make_unique<HashSink>(HashType::SHA256);
+ hashSink = std::make_unique<HashSink>(htSHA256);
else
- hashSink = std::make_unique<HashModuloSink>(HashType::SHA256, std::string(info.path.hashPart()));
+ hashSink = std::make_unique<HashModuloSink>(htSHA256, std::string(info.path.hashPart()));
LambdaSource wrapperSource([&](unsigned char * data, size_t len) -> size_t {
size_t n = source.read(data, len);
@@ -1008,7 +1008,7 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
if (hashResult.first != info.narHash)
throw Error("hash mismatch importing path '%s';\n wanted: %s\n got: %s",
- printStorePath(info.path), info.narHash.to_string(Base::Base32, true), hashResult.first.to_string(Base::Base32, true));
+ printStorePath(info.path), info.narHash.to_string(Base32, true), hashResult.first.to_string(Base32, true));
if (hashResult.second != info.narSize)
throw Error("size mismatch importing path '%s';\n wanted: %s\n got: %s",
@@ -1067,10 +1067,10 @@ StorePath LocalStore::addToStoreFromDump(const string & dump, const string & nam
sha256); otherwise, compute it here. */
HashResult hash;
if (method == FileIngestionMethod::Recursive) {
- hash.first = hashAlgo == HashType::SHA256 ? h : hashString(HashType::SHA256, dump);
+ hash.first = hashAlgo == htSHA256 ? h : hashString(htSHA256, dump);
hash.second = dump.size();
} else
- hash = hashPath(HashType::SHA256, realPath);
+ hash = hashPath(htSHA256, realPath);
optimisePath(realPath); // FIXME: combine with hashPath()
@@ -1109,7 +1109,7 @@ StorePath LocalStore::addToStore(const string & name, const Path & _srcPath,
StorePath LocalStore::addTextToStore(const string & name, const string & s,
const StorePathSet & references, RepairFlag repair)
{
- auto hash = hashString(HashType::SHA256, s);
+ auto hash = hashString(htSHA256, s);
auto dstPath = makeTextPath(name, hash, references);
addTempRoot(dstPath);
@@ -1133,7 +1133,7 @@ StorePath LocalStore::addTextToStore(const string & name, const string & s,
StringSink sink;
dumpString(s, sink);
- auto narHash = hashString(HashType::SHA256, *sink.s);
+ auto narHash = hashString(htSHA256, *sink.s);
optimisePath(realPath);
@@ -1141,7 +1141,7 @@ StorePath LocalStore::addTextToStore(const string & name, const string & s,
info.narHash = narHash;
info.narSize = sink.s->size();
info.references = references;
- info.ca = "text:" + hash.to_string(Base::Base32, true);
+ info.ca = "text:" + hash.to_string(Base32, true);
registerValidPath(info);
}
@@ -1219,9 +1219,9 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
printInfo("checking link hashes...");
for (auto & link : readDirectory(linksDir)) {
- printMsg(Verbosity::Talkative, "checking contents of '%s'", link.name);
+ printMsg(lvlTalkative, "checking contents of '%s'", link.name);
Path linkPath = linksDir + "/" + link.name;
- string hash = hashPath(HashType::SHA256, linkPath).first.to_string(Base::Base32, false);
+ string hash = hashPath(htSHA256, linkPath).first.to_string(Base32, false);
if (hash != link.name) {
logError({
.name = "Invalid hash",
@@ -1242,14 +1242,14 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
printInfo("checking store hashes...");
- Hash nullHash(HashType::SHA256);
+ Hash nullHash(htSHA256);
for (auto & i : validPaths) {
try {
auto info = std::const_pointer_cast<ValidPathInfo>(std::shared_ptr<const ValidPathInfo>(queryPathInfo(i)));
/* Check the content hash (optionally - slow). */
- printMsg(Verbosity::Talkative, "checking contents of '%s'", printStorePath(i));
+ printMsg(lvlTalkative, "checking contents of '%s'", printStorePath(i));
std::unique_ptr<AbstractHashSink> hashSink;
if (info->ca == "" || !info->references.count(info->path))
@@ -1264,7 +1264,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
logError({
.name = "Invalid hash - path modified",
.hint = hintfmt("path '%s' was modified! expected hash '%s', got '%s'",
- printStorePath(i), info->narHash.to_string(Base::Base32, true), current.first.to_string(Base::Base32, true))
+ printStorePath(i), info->narHash.to_string(Base32, true), current.first.to_string(Base32, true))
});
if (repair) repairPath(i); else errors = true;
} else {
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 90d921a2a..e17cc45ae 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -155,7 +155,7 @@ public:
true) or simply the contents of a regular file (if recursive ==
false). */
StorePath addToStoreFromDump(const string & dump, const string & name,
- FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = HashType::SHA256, RepairFlag repair = NoRepair) override;
+ FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = htSHA256, RepairFlag repair = NoRepair) override;
StorePath addTextToStore(const string & name, const string & s,
const StorePathSet & references, RepairFlag repair) override;
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index 369fbbd37..e68edb38c 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -112,7 +112,7 @@ void Store::queryMissing(const std::vector<StorePathWithOutputs> & targets,
StorePathSet & willBuild_, StorePathSet & willSubstitute_, StorePathSet & unknown_,
unsigned long long & downloadSize_, unsigned long long & narSize_)
{
- Activity act(*logger, Verbosity::Debug, ActivityType::Unknown, "querying info about missing paths");
+ Activity act(*logger, lvlDebug, actUnknown, "querying info about missing paths");
downloadSize_ = narSize_ = 0;
diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc
index c5da5a6be..552970248 100644
--- a/src/libstore/nar-info-disk-cache.cc
+++ b/src/libstore/nar-info-disk-cache.cc
@@ -230,9 +230,9 @@ public:
(std::string(info->path.name()))
(narInfo ? narInfo->url : "", narInfo != 0)
(narInfo ? narInfo->compression : "", narInfo != 0)
- (narInfo && narInfo->fileHash ? narInfo->fileHash.to_string(Base::Base32, true) : "", narInfo && narInfo->fileHash)
+ (narInfo && narInfo->fileHash ? narInfo->fileHash.to_string(Base32, true) : "", narInfo && narInfo->fileHash)
(narInfo ? narInfo->fileSize : 0, narInfo != 0 && narInfo->fileSize)
- (info->narHash.to_string(Base::Base32, true))
+ (info->narHash.to_string(Base32, true))
(info->narSize)
(concatStringsSep(" ", info->shortRefs()))
(info->deriver ? std::string(info->deriver->to_string()) : "", (bool) info->deriver)
diff --git a/src/libstore/nar-info.cc b/src/libstore/nar-info.cc
index ade132d58..bb4448c90 100644
--- a/src/libstore/nar-info.cc
+++ b/src/libstore/nar-info.cc
@@ -86,11 +86,11 @@ std::string NarInfo::to_string(const Store & store) const
res += "URL: " + url + "\n";
assert(compression != "");
res += "Compression: " + compression + "\n";
- assert(fileHash.type == HashType::SHA256);
- res += "FileHash: " + fileHash.to_string(Base::Base32, true) + "\n";
+ assert(fileHash.type == htSHA256);
+ res += "FileHash: " + fileHash.to_string(Base32, true) + "\n";
res += "FileSize: " + std::to_string(fileSize) + "\n";
- assert(narHash.type == HashType::SHA256);
- res += "NarHash: " + narHash.to_string(Base::Base32, true) + "\n";
+ assert(narHash.type == htSHA256);
+ res += "NarHash: " + narHash.to_string(Base32, true) + "\n";
res += "NarSize: " + std::to_string(narSize) + "\n";
res += "References: " + concatStringsSep(" ", shortRefs()) + "\n";
diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc
index 820243d30..b2b2412a3 100644
--- a/src/libstore/optimise-store.cc
+++ b/src/libstore/optimise-store.cc
@@ -57,7 +57,7 @@ LocalStore::InodeHash LocalStore::loadInodeHash()
}
if (errno) throw SysError("reading directory '%1%'", linksDir);
- printMsg(Verbosity::Talkative, format("loaded %1% hash inodes") % inodeHash.size());
+ printMsg(lvlTalkative, format("loaded %1% hash inodes") % inodeHash.size());
return inodeHash;
}
@@ -152,11 +152,11 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
Also note that if `path' is a symlink, then we're hashing the
contents of the symlink (i.e. the result of readlink()), not
the contents of the target (which may not even exist). */
- Hash hash = hashPath(HashType::SHA256, path).first;
- debug(format("'%1%' has hash '%2%'") % path % hash.to_string(Base::Base32, true));
+ Hash hash = hashPath(htSHA256, path).first;
+ debug(format("'%1%' has hash '%2%'") % path % hash.to_string(Base32, true));
/* Check if this is a known hash. */
- Path linkPath = linksDir + "/" + hash.to_string(Base::Base32, false);
+ Path linkPath = linksDir + "/" + hash.to_string(Base32, false);
retry:
if (!pathExists(linkPath)) {
@@ -205,7 +205,7 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
goto retry;
}
- printMsg(Verbosity::Talkative, format("linking '%1%' to '%2%'") % path % linkPath);
+ printMsg(lvlTalkative, format("linking '%1%' to '%2%'") % path % linkPath);
/* Make the containing directory writable, but only if it's not
the store itself (we don't want or need to mess with its
@@ -255,13 +255,13 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
stats.blocksFreed += st.st_blocks;
if (act)
- act->result(ResultType::FileLinked, st.st_size, st.st_blocks);
+ act->result(resFileLinked, st.st_size, st.st_blocks);
}
void LocalStore::optimiseStore(OptimiseStats & stats)
{
- Activity act(*logger, ActivityType::OptimiseStore);
+ Activity act(*logger, actOptimiseStore);
auto paths = queryAllValidPaths();
InodeHash inodeHash = loadInodeHash();
@@ -274,7 +274,7 @@ void LocalStore::optimiseStore(OptimiseStats & stats)
addTempRoot(i);
if (!isValidPath(i)) continue; /* path was GC'ed, probably */
{
- Activity act(*logger, Verbosity::Talkative, ActivityType::Unknown, fmt("optimising path '%s'", printStorePath(i)));
+ Activity act(*logger, lvlTalkative, actUnknown, fmt("optimising path '%s'", printStorePath(i)));
optimisePath_(&act, stats, realStoreDir + "/" + std::string(i.to_string()), inodeHash);
}
done++;
diff --git a/src/libstore/path.cc b/src/libstore/path.cc
index 70a336c05..b3d8ce95c 100644
--- a/src/libstore/path.cc
+++ b/src/libstore/path.cc
@@ -31,7 +31,7 @@ StorePath::StorePath(std::string_view _baseName)
}
StorePath::StorePath(const Hash & hash, std::string_view _name)
- : baseName((hash.to_string(Base::Base32, false) + "-").append(std::string(_name)))
+ : baseName((hash.to_string(Base32, false) + "-").append(std::string(_name)))
{
checkName(baseName, name());
}
diff --git a/src/libstore/references.cc b/src/libstore/references.cc
index 839fd13db..a10d536a3 100644
--- a/src/libstore/references.cc
+++ b/src/libstore/references.cc
@@ -54,7 +54,7 @@ struct RefScanSink : Sink
string tail;
- RefScanSink() : hashSink(HashType::SHA256) { }
+ RefScanSink() : hashSink(htSHA256) { }
void operator () (const unsigned char * data, size_t len);
};
@@ -96,7 +96,7 @@ PathSet scanForReferences(const string & path,
string s = string(baseName, 0, pos);
assert(s.size() == refLength);
assert(backMap.find(s) == backMap.end());
- // parseHash(HashType::SHA256, s);
+ // parseHash(htSHA256, s);
sink.hashes.insert(s);
backMap[s] = i;
}
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index dcd3b7cbf..f5f2ab7fd 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -177,11 +177,11 @@ void RemoteStore::setOptions(Connection & conn)
<< settings.keepFailed
<< settings.keepGoing
<< settings.tryFallback
- << (uint64_t) verbosity
+ << verbosity
<< settings.maxBuildJobs
<< settings.maxSilentTime
<< true
- << (uint64_t) (settings.verboseBuild ? Verbosity::Error : Verbosity::Vomit)
+ << (settings.verboseBuild ? lvlError : lvlVomit)
<< 0 // obsolete log type
<< 0 /* obsolete print build trace */
<< settings.buildCores
@@ -375,7 +375,7 @@ void RemoteStore::queryPathInfoUncached(const StorePath & path,
info = std::make_shared<ValidPathInfo>(StorePath(path));
auto deriver = readString(conn->from);
if (deriver != "") info->deriver = parseStorePath(deriver);
- info->narHash = Hash(readString(conn->from), HashType::SHA256);
+ info->narHash = Hash(readString(conn->from), htSHA256);
info->references = readStorePaths<StorePathSet>(*this, conn->from);
conn->from >> info->registrationTime >> info->narSize;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 16) {
@@ -462,7 +462,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
conn->to << wopAddToStoreNar
<< printStorePath(info.path)
<< (info.deriver ? printStorePath(*info.deriver) : "")
- << info.narHash.to_string(Base::Base16, false);
+ << info.narHash.to_string(Base16, false);
writeStorePaths(*this, conn->to, info.references);
conn->to << info.registrationTime << info.narSize
<< info.ultimate << info.sigs << info.ca
@@ -486,7 +486,7 @@ StorePath RemoteStore::addToStore(const string & name, const Path & _srcPath,
conn->to
<< wopAddToStore
<< name
- << ((hashAlgo == HashType::SHA256 && method == FileIngestionMethod::Recursive) ? 0 : 1) /* backwards compatibility hack */
+ << ((hashAlgo == htSHA256 && method == FileIngestionMethod::Recursive) ? 0 : 1) /* backwards compatibility hack */
<< (method == FileIngestionMethod::Recursive ? 1 : 0)
<< printHashType(hashAlgo);
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index 0908b511e..80c8e9f11 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -63,7 +63,7 @@ public:
std::shared_ptr<FSAccessor> accessor) override;
StorePath addToStore(const string & name, const Path & srcPath,
- FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = HashType::SHA256,
+ FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = htSHA256,
PathFilter & filter = defaultPathFilter, RepairFlag repair = NoRepair) override;
StorePath addTextToStore(const string & name, const string & s,
diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc
index 9fc6da9bf..427dd48ce 100644
--- a/src/libstore/s3-binary-cache-store.cc
+++ b/src/libstore/s3-binary-cache-store.cc
@@ -70,9 +70,9 @@ static void initAWS()
shared.cc), so don't let aws-sdk-cpp override it. */
options.cryptoOptions.initAndCleanupOpenSSL = false;
- if (verbosity >= Verbosity::Debug) {
+ if (verbosity >= lvlDebug) {
options.loggingOptions.logLevel =
- verbosity == Verbosity::Debug
+ verbosity == lvlDebug
? Aws::Utils::Logging::LogLevel::Debug
: Aws::Utils::Logging::LogLevel::Trace;
options.loggingOptions.logger_create_fn = [options]() {
diff --git a/src/libstore/ssh.cc b/src/libstore/ssh.cc
index f61c094a2..84548a6e4 100644
--- a/src/libstore/ssh.cc
+++ b/src/libstore/ssh.cc
@@ -58,7 +58,7 @@ std::unique_ptr<SSHMaster::Connection> SSHMaster::startCommand(const std::string
addCommonSSHOpts(args);
if (socketPath != "")
args.insert(args.end(), {"-S", socketPath});
- if (verbosity >= Verbosity::Chatty)
+ if (verbosity >= lvlChatty)
args.push_back("-v");
}
@@ -110,7 +110,7 @@ Path SSHMaster::startMaster()
, "-o", "LocalCommand=echo started"
, "-o", "PermitLocalCommand=yes"
};
- if (verbosity >= Verbosity::Chatty)
+ if (verbosity >= lvlChatty)
args.push_back("-v");
addCommonSSHOpts(args);
execvp(args.begin()->c_str(), stringsToCharPtrs(args).data());
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 5857b6f34..2615a43d4 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -143,8 +143,8 @@ StorePath Store::makeStorePath(const string & type,
const Hash & hash, std::string_view name) const
{
/* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
- string s = type + ":" + hash.to_string(Base::Base16, true) + ":" + storeDir + ":" + std::string(name);
- auto h = compressHash(hashString(HashType::SHA256, s), 20);
+ string s = type + ":" + hash.to_string(Base16, true) + ":" + storeDir + ":" + std::string(name);
+ auto h = compressHash(hashString(htSHA256, s), 20);
return StorePath(h, name);
}
@@ -179,15 +179,15 @@ StorePath Store::makeFixedOutputPath(
const StorePathSet & references,
bool hasSelfReference) const
{
- if (hash.type == HashType::SHA256 && recursive == FileIngestionMethod::Recursive) {
+ if (hash.type == htSHA256 && recursive == FileIngestionMethod::Recursive) {
return makeStorePath(makeType(*this, "source", references, hasSelfReference), hash, name);
} else {
assert(references.empty());
return makeStorePath("output:out",
- hashString(HashType::SHA256,
+ hashString(htSHA256,
"fixed:out:"
+ (recursive == FileIngestionMethod::Recursive ? (string) "r:" : "")
- + hash.to_string(Base::Base16, true) + ":"),
+ + hash.to_string(Base16, true) + ":"),
name);
}
}
@@ -196,7 +196,7 @@ StorePath Store::makeFixedOutputPath(
StorePath Store::makeTextPath(std::string_view name, const Hash & hash,
const StorePathSet & references) const
{
- assert(hash.type == HashType::SHA256);
+ assert(hash.type == htSHA256);
/* Stuff the references (if any) into the type. This is a bit
hacky, but we can't put them in `s' since that would be
ambiguous. */
@@ -217,7 +217,7 @@ std::pair<StorePath, Hash> Store::computeStorePathForPath(std::string_view name,
StorePath Store::computeStorePathForText(const string & name, const string & s,
const StorePathSet & references) const
{
- return makeTextPath(name, hashString(HashType::SHA256, s), references);
+ return makeTextPath(name, hashString(htSHA256, s), references);
}
@@ -430,7 +430,7 @@ string Store::makeValidityRegistration(const StorePathSet & paths,
auto info = queryPathInfo(i);
if (showHash) {
- s += info->narHash.to_string(Base::Base16, false) + "\n";
+ s += info->narHash.to_string(Base16, false) + "\n";
s += (format("%1%\n") % info->narSize).str();
}
@@ -505,7 +505,7 @@ void Store::pathInfoToJSON(JSONPlaceholder & jsonOut, const StorePathSet & store
if (!narInfo->url.empty())
jsonPath.attr("url", narInfo->url);
if (narInfo->fileHash)
- jsonPath.attr("downloadHash", narInfo->fileHash.to_string(Base::Base32, true));
+ jsonPath.attr("downloadHash", narInfo->fileHash.to_string(Base32, true));
if (narInfo->fileSize)
jsonPath.attr("downloadSize", narInfo->fileSize);
if (showClosureSize)
@@ -568,7 +568,7 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
auto srcUri = srcStore->getUri();
auto dstUri = dstStore->getUri();
- Activity act(*logger, Verbosity::Info, ActivityType::CopyPath,
+ Activity act(*logger, lvlInfo, actCopyPath,
srcUri == "local" || srcUri == "daemon"
? fmt("copying path '%s' to '%s'", srcStore->printStorePath(storePath), dstUri)
: dstUri == "local" || dstUri == "daemon"
@@ -585,7 +585,7 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
StringSink sink;
srcStore->narFromPath({storePath}, sink);
auto info2 = make_ref<ValidPathInfo>(*info);
- info2->narHash = hashString(HashType::SHA256, *sink.s);
+ info2->narHash = hashString(htSHA256, *sink.s);
if (!info->narSize) info2->narSize = sink.s->size();
if (info->ultimate) info2->ultimate = false;
info = info2;
@@ -627,7 +627,7 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
if (missing.empty()) return;
- Activity act(*logger, Verbosity::Info, ActivityType::CopyPaths, fmt("copying %d paths", missing.size()));
+ Activity act(*logger, lvlInfo, actCopyPaths, fmt("copying %d paths", missing.size()));
std::atomic<size_t> nrDone{0};
std::atomic<size_t> nrFailed{0};
@@ -653,7 +653,7 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
auto info = srcStore->queryPathInfo(srcStore->parseStorePath(storePath));
bytesExpected += info->narSize;
- act.setExpected(ActivityType::CopyPath, bytesExpected);
+ act.setExpected(actCopyPath, bytesExpected);
return srcStore->printStorePathSet(info->references);
},
@@ -672,7 +672,7 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
nrFailed++;
if (!settings.keepGoing)
throw e;
- logger->log(Verbosity::Error, fmt("could not copy %s: %s", storePathS, e.what()));
+ logger->log(lvlError, fmt("could not copy %s: %s", storePathS, e.what()));
showProgress();
return;
}
@@ -703,7 +703,7 @@ std::optional<ValidPathInfo> decodeValidPathInfo(const Store & store, std::istre
if (hashGiven) {
string s;
getline(str, s);
- info.narHash = Hash(s, HashType::SHA256);
+ info.narHash = Hash(s, htSHA256);
getline(str, s);
if (!string2Int(s, info.narSize)) throw Error("number expected");
}
@@ -746,7 +746,7 @@ std::string ValidPathInfo::fingerprint(const Store & store) const
store.printStorePath(path));
return
"1;" + store.printStorePath(path) + ";"
- + narHash.to_string(Base::Base32, true) + ";"
+ + narHash.to_string(Base32, true) + ";"
+ std::to_string(narSize) + ";"
+ concatStringsSep(",", store.printStorePathSet(references));
}
@@ -826,7 +826,7 @@ std::string makeFixedOutputCA(FileIngestionMethod recursive, const Hash & hash)
{
return "fixed:"
+ (recursive == FileIngestionMethod::Recursive ? (std::string) "r:" : "")
- + hash.to_string(Base::Base32, true);
+ + hash.to_string(Base32, true);
}
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 072aebc8d..6f4dd959c 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -360,7 +360,7 @@ public:
path and the cryptographic hash of the contents of srcPath. */
std::pair<StorePath, Hash> computeStorePathForPath(std::string_view name,
const Path & srcPath, FileIngestionMethod method = FileIngestionMethod::Recursive,
- HashType hashAlgo = HashType::SHA256, PathFilter & filter = defaultPathFilter) const;
+ HashType hashAlgo = htSHA256, PathFilter & filter = defaultPathFilter) const;
/* Preparatory part of addTextToStore().
@@ -454,12 +454,12 @@ public:
The function object `filter' can be used to exclude files (see
libutil/archive.hh). */
virtual StorePath addToStore(const string & name, const Path & srcPath,
- FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = HashType::SHA256,
+ FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = htSHA256,
PathFilter & filter = defaultPathFilter, RepairFlag repair = NoRepair) = 0;
// FIXME: remove?
virtual StorePath addToStoreFromDump(const string & dump, const string & name,
- FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = HashType::SHA256, RepairFlag repair = NoRepair)
+ FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = htSHA256, RepairFlag repair = NoRepair)
{
throw Error("addToStoreFromDump() is not supported by this store");
}
@@ -553,7 +553,7 @@ public:
each path is included. */
void pathInfoToJSON(JSONPlaceholder & jsonOut, const StorePathSet & storePaths,
bool includeImpureInfo, bool showClosureSize,
- Base hashBase = Base::Base32,
+ Base hashBase = Base32,
AllowInvalidFlag allowInvalid = DisallowInvalid);
/* Return the size of the closure of the specified path, that is,