printMsg(lvlError, ...) -> printError(...) etc.

This commit is contained in:
Eelco Dolstra 2016-09-21 16:11:01 +02:00
parent 4036185cb4
commit c55bf085eb
30 changed files with 140 additions and 140 deletions

View file

@ -1014,7 +1014,7 @@ void DerivationGoal::loadDerivation()
trace("loading derivation");
if (nrFailed != 0) {
printMsg(lvlError, format("cannot build missing derivation %1%") % drvPath);
printError(format("cannot build missing derivation %1%") % drvPath);
done(BuildResult::MiscFailure);
return;
}
@ -1168,7 +1168,7 @@ void DerivationGoal::repairClosure()
PathSet broken;
for (auto & i : outputClosure) {
if (worker.pathContentsGood(i)) continue;
printMsg(lvlError, format("found corrupted or missing path %1% in the output closure of %2%") % i % drvPath);
printError(format("found corrupted or missing path %1% in the output closure of %2%") % i % drvPath);
Path drvPath2 = outputsToDrv[i];
if (drvPath2 == "")
addWaitee(worker.makeSubstitutionGoal(i, true));
@ -1201,7 +1201,7 @@ void DerivationGoal::inputsRealised()
if (nrFailed != 0) {
if (!useDerivation)
throw Error(format("some dependencies of %1% are missing") % drvPath);
printMsg(lvlError,
printError(
format("cannot build derivation %1%: %2% dependencies couldn't be built")
% drvPath % nrFailed);
done(BuildResult::DependencyFailed);
@ -1366,7 +1366,7 @@ void DerivationGoal::tryToBuild()
startBuilder();
} catch (BuildError & e) {
printMsg(lvlError, e.msg());
printError(e.msg());
outputLocks.unlock();
buildUser.release();
worker.permanentFailure = true;
@ -1515,7 +1515,7 @@ void DerivationGoal::buildDone()
} catch (BuildError & e) {
if (!hook)
printMsg(lvlError, e.msg());
printError(e.msg());
outputLocks.unlock();
buildUser.release();
@ -1644,7 +1644,7 @@ void DerivationGoal::startBuilder()
nrRounds > 1 ? "building path(s) %1% (round %2%/%3%)" :
"building path(s) %1%");
f.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
printMsg(lvlInfo, f % showPaths(missingPaths) % curRound % nrRounds);
printInfo(f % showPaths(missingPaths) % curRound % nrRounds);
/* Right platform? */
if (!drv->canBuildLocally()) {
@ -2216,7 +2216,7 @@ void DerivationGoal::startBuilder()
if (msg.size() == 1) break;
throw Error(string(msg, 1));
}
printMsg(lvlDebug, msg);
debug(msg);
}
}
@ -2704,7 +2704,7 @@ void DerivationGoal::registerOutputs()
/* Apply hash rewriting if necessary. */
bool rewritten = false;
if (!outputRewrites.empty()) {
printMsg(lvlError, format("warning: rewriting hashes in %1%; cross fingers") % path);
printError(format("warning: rewriting hashes in %1%; cross fingers") % path);
/* Canonicalise first. This ensures that the path we're
rewriting doesn't contain a hard link to /etc/shadow or
@ -2743,7 +2743,7 @@ void DerivationGoal::registerOutputs()
Hash h2 = recursive ? hashPath(h.type, actualPath).first : hashFile(h.type, actualPath);
if (buildMode == bmHash) {
Path dest = worker.store.makeFixedOutputPath(recursive, h2, drv->env["name"]);
printMsg(lvlError, format("build produced path %1% with %2% hash %3%")
printError(format("build produced path %1% with %2% hash %3%")
% dest % printHashType(h.type) % printHash16or32(h2));
if (worker.store.isValidPath(dest))
return;
@ -2967,7 +2967,7 @@ void DerivationGoal::deleteTmpDir(bool force)
{
if (tmpDir != "") {
if (settings.keepFailed && !force) {
printMsg(lvlError,
printError(
format("note: keeping build directory %2%")
% drvPath % tmpDir);
chmod(tmpDir.c_str(), 0755);
@ -2986,7 +2986,7 @@ void DerivationGoal::handleChildOutput(int fd, const string & data)
{
logSize += data.size();
if (settings.maxLogSize && logSize > settings.maxLogSize) {
printMsg(lvlError,
printError(
format("%1% killed after writing more than %2% bytes of log output")
% getName() % settings.maxLogSize);
killChild();
@ -3009,7 +3009,7 @@ void DerivationGoal::handleChildOutput(int fd, const string & data)
}
if (hook && fd == hook->fromHook.readSide.get())
printMsg(lvlError, data); // FIXME?
printError(data); // FIXME?
}
@ -3023,7 +3023,7 @@ void DerivationGoal::handleEOF(int fd)
void DerivationGoal::flushLine()
{
if (settings.verboseBuild)
printMsg(lvlInfo, filterANSIEscapes(currentLogLine, true));
printInfo(filterANSIEscapes(currentLogLine, true));
else {
logTail.push_back(currentLogLine);
if (logTail.size() > settings.logLines) logTail.pop_front();
@ -3236,7 +3236,7 @@ void SubstitutionGoal::tryNext()
signature. LocalStore::addToStore() also checks for this, but
only after we've downloaded the path. */
if (worker.store.requireSigs && !info->checkSignatures(worker.store, worker.store.publicKeys)) {
printMsg(lvlInfo, format("warning: substituter %s does not have a valid signature for path %s")
printInfo(format("warning: substituter %s does not have a valid signature for path %s")
% sub->getUri() % storePath);
tryNext();
return;
@ -3287,7 +3287,7 @@ void SubstitutionGoal::tryToRun()
return;
}
printMsg(lvlInfo, format("fetching path %1%...") % storePath);
printInfo(format("fetching path %1%...") % storePath);
outPipe.create();
@ -3323,7 +3323,7 @@ void SubstitutionGoal::finished()
try {
promise.get_future().get();
} catch (Error & e) {
printMsg(lvlInfo, e.msg());
printInfo(e.msg());
/* Try the next substitute. */
state = &SubstitutionGoal::tryNext;
@ -3617,7 +3617,7 @@ void Worker::waitForInput()
if (!waitingForAWhile.empty()) {
useTimeout = true;
if (lastWokenUp == 0)
printMsg(lvlError, "waiting for locks or build slots...");
printError("waiting for locks or build slots...");
if (lastWokenUp == 0 || lastWokenUp > before) lastWokenUp = before;
timeout.tv_sec = std::max((time_t) 1, (time_t) (lastWokenUp + settings.pollInterval - before));
} else lastWokenUp = 0;
@ -3680,7 +3680,7 @@ void Worker::waitForInput()
j->respectTimeouts &&
after - j->lastOutput >= (time_t) settings.maxSilentTime)
{
printMsg(lvlError,
printError(
format("%1% timed out after %2% seconds of silence")
% goal->getName() % settings.maxSilentTime);
goal->timedOut();
@ -3691,7 +3691,7 @@ void Worker::waitForInput()
j->respectTimeouts &&
after - j->timeStarted >= (time_t) settings.buildTimeout)
{
printMsg(lvlError,
printError(
format("%1% timed out after %2% seconds")
% goal->getName() % settings.buildTimeout);
goal->timedOut();
@ -3719,7 +3719,7 @@ bool Worker::pathContentsGood(const Path & path)
{
std::map<Path, bool>::iterator i = pathContentsGoodCache.find(path);
if (i != pathContentsGoodCache.end()) return i->second;
printMsg(lvlInfo, format("checking path %1%...") % path);
printInfo(format("checking path %1%...") % path);
auto info = store.queryPathInfo(path);
bool res;
if (!pathExists(path))
@ -3730,7 +3730,7 @@ bool Worker::pathContentsGood(const Path & path)
res = info->narHash == nullHash || info->narHash == current.first;
}
pathContentsGoodCache[path] = res;
if (!res) printMsg(lvlError, format("path %1% is corrupted or missing!") % path);
if (!res) printError(format("path %1% is corrupted or missing!") % path);
return res;
}

View file

@ -265,7 +265,7 @@ struct CurlDownloader : public Downloader
download after a while. */
if (err == Transient && attempt < request.tries) {
int ms = request.baseRetryTimeMs * std::pow(2.0f, attempt - 1 + std::uniform_real_distribution<>(0.0, 0.5)(downloader.mt19937));
printMsg(lvlError, format("warning: %s; retrying in %d ms") % exc.what() % ms);
printError(format("warning: %s; retrying in %d ms") % exc.what() % ms);
embargo = std::chrono::steady_clock::now() + std::chrono::milliseconds(ms);
downloader.enqueueItem(shared_from_this());
}
@ -420,7 +420,7 @@ struct CurlDownloader : public Downloader
workerThreadMain();
} catch (nix::Interrupted & e) {
} catch (std::exception & e) {
printMsg(lvlError, format("unexpected error in download thread: %s") % e.what());
printError(format("unexpected error in download thread: %s") % e.what());
}
{
@ -522,7 +522,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
if (effectiveUrl)
*effectiveUrl = url_;
} else if (!ss[1].empty()) {
printMsg(lvlDebug, format("verifying previous ETag %1%") % ss[1]);
debug(format("verifying previous ETag %1%") % ss[1]);
expectedETag = ss[1];
}
}
@ -556,7 +556,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
writeFile(dataFile, url + "\n" + res.etag + "\n" + std::to_string(time(0)) + "\n");
} catch (DownloadError & e) {
if (storePath.empty()) throw;
printMsg(lvlError, format("warning: %1%; using cached result") % e.msg());
printError(format("warning: %1%; using cached result") % e.msg());
}
}
@ -570,7 +570,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
unpackedStorePath = "";
}
if (unpackedStorePath.empty()) {
printMsg(lvlInfo, format("unpacking %1%...") % url);
printInfo(format("unpacking %1%...") % url);
Path tmpDir = createTempDir();
AutoDelete autoDelete(tmpDir, true);
// FIXME: this requires GNU tar for decompression.

View file

@ -39,7 +39,7 @@ int LocalStore::openGCLock(LockType lockType)
throw SysError(format("opening global GC lock %1%") % fnGCLock);
if (!lockFile(fdGCLock.get(), lockType, false)) {
printMsg(lvlError, format("waiting for the big garbage collector lock..."));
printError(format("waiting for the big garbage collector lock..."));
lockFile(fdGCLock.get(), lockType, true);
}
@ -129,7 +129,7 @@ Path LocalFSStore::addPermRoot(const Path & _storePath,
if (settings.checkRootReachability) {
Roots roots = findRoots();
if (roots.find(gcRoot) == roots.end())
printMsg(lvlError,
printError(
format(
"warning: %1% is not in a directory where the garbage collector looks for roots; "
"therefore, %2% might be removed by the garbage collector")
@ -226,7 +226,7 @@ void LocalStore::readTempRoots(PathSet & tempRoots, FDs & fds)
only succeed if the owning process has died. In that case
we don't care about its temporary roots. */
if (lockFile(fd->get(), ltWrite, false)) {
printMsg(lvlError, format("removing stale temporary roots file %1%") % path);
printError(format("removing stale temporary roots file %1%") % path);
unlink(path.c_str());
writeFull(fd->get(), "d");
continue;
@ -264,7 +264,7 @@ void LocalStore::findRoots(const Path & path, unsigned char type, Roots & roots)
if (isStorePath(storePath) && isValidPath(storePath))
roots[path] = storePath;
else
printMsg(lvlInfo, format("skipping invalid root from %1% to %2%") % path % storePath);
printInfo(format("skipping invalid root from %1% to %2%") % path % storePath);
};
try {
@ -287,7 +287,7 @@ void LocalStore::findRoots(const Path & path, unsigned char type, Roots & roots)
target = absPath(target, dirOf(path));
if (!pathExists(target)) {
if (isInDir(path, stateDir + "/" + gcRootsDir + "/auto")) {
printMsg(lvlInfo, format("removing stale link from %1% to %2%") % path % target);
printInfo(format("removing stale link from %1% to %2%") % path % target);
unlink(path.c_str());
}
} else {
@ -310,7 +310,7 @@ void LocalStore::findRoots(const Path & path, unsigned char type, Roots & roots)
catch (SysError & e) {
/* We only ignore permanent failures. */
if (e.errNo == EACCES || e.errNo == ENOENT || e.errNo == ENOTDIR)
printMsg(lvlInfo, format("cannot read potential root %1%") % path);
printInfo(format("cannot read potential root %1%") % path);
else
throw;
}
@ -513,7 +513,7 @@ void LocalStore::deletePathRecursive(GCState & state, const Path & path)
throw SysError(format("getting status of %1%") % realPath);
}
printMsg(lvlInfo, format("deleting %1%") % path);
printInfo(format("deleting %1%") % path);
state.results.paths.insert(path);
@ -535,7 +535,7 @@ void LocalStore::deletePathRecursive(GCState & state, const Path & path)
state.bytesInvalidated += size;
} catch (SysError & e) {
if (e.errNo == ENOSPC) {
printMsg(lvlInfo, format("note: can't create move %1%: %2%") % realPath % e.msg());
printInfo(format("note: can't create move %1%: %2%") % realPath % e.msg());
deleteGarbage(state, realPath);
}
}
@ -543,7 +543,7 @@ void LocalStore::deletePathRecursive(GCState & state, const Path & path)
deleteGarbage(state, realPath);
if (state.results.bytesFreed + state.bytesInvalidated > state.options.maxFreed) {
printMsg(lvlInfo, format("deleted or invalidated more than %1% bytes; stopping") % state.options.maxFreed);
printInfo(format("deleted or invalidated more than %1% bytes; stopping") % state.options.maxFreed);
throw GCLimitReached();
}
}
@ -562,7 +562,7 @@ bool LocalStore::canReachRoot(GCState & state, PathSet & visited, const Path & p
}
if (state.roots.find(path) != state.roots.end()) {
printMsg(lvlDebug, format("cannot delete %1% because it's a root") % path);
debug(format("cannot delete %1% because it's a root") % path);
state.alive.insert(path);
return true;
}
@ -626,7 +626,7 @@ void LocalStore::tryToDelete(GCState & state, const Path & path)
PathSet visited;
if (canReachRoot(state, visited, path)) {
printMsg(lvlDebug, format("cannot delete %1% because it's still reachable") % path);
debug(format("cannot delete %1% because it's still reachable") % path);
} else {
/* No path we visited was a root, so everything is garbage.
But we only delete path and its referrers here so that
@ -682,7 +682,7 @@ void LocalStore::removeUnusedLinks(const GCState & state)
throw SysError(format("statting %1%") % linksDir);
long long overhead = st.st_blocks * 512ULL;
printMsg(lvlInfo, format("note: currently hard linking saves %.2f MiB")
printInfo(format("note: currently hard linking saves %.2f MiB")
% ((unsharedSize - actualSize - overhead) / (1024.0 * 1024.0)));
}
@ -715,7 +715,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
/* Find the roots. Since we've grabbed the GC lock, the set of
permanent roots cannot increase now. */
printMsg(lvlError, format("finding garbage collector roots..."));
printError(format("finding garbage collector roots..."));
Roots rootMap = options.ignoreLiveness ? Roots() : findRoots();
for (auto & i : rootMap) state.roots.insert(i.second);
@ -744,7 +744,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
createDirs(trashDir);
} catch (SysError & e) {
if (e.errNo == ENOSPC) {
printMsg(lvlInfo, format("note: can't create trash directory: %1%") % e.msg());
printInfo(format("note: can't create trash directory: %1%") % e.msg());
state.moveToTrash = false;
}
}
@ -765,9 +765,9 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
} else if (options.maxFreed > 0) {
if (state.shouldDelete)
printMsg(lvlError, format("deleting garbage..."));
printError(format("deleting garbage..."));
else
printMsg(lvlError, format("determining live/dead paths..."));
printError(format("determining live/dead paths..."));
try {
@ -825,12 +825,12 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
fds.clear();
/* Delete the trash directory. */
printMsg(lvlInfo, format("deleting %1%") % trashDir);
printInfo(format("deleting %1%") % trashDir);
deleteGarbage(state, trashDir);
/* Clean up the links directory. */
if (options.action == GCOptions::gcDeleteDead || options.action == GCOptions::gcDeleteSpecific) {
printMsg(lvlError, format("deleting unused links..."));
printError(format("deleting unused links..."));
removeUnusedLinks(state);
}

View file

@ -76,7 +76,7 @@ LocalStore::LocalStore(const Params & params)
struct group * gr = getgrnam(settings.buildUsersGroup.c_str());
if (!gr)
printMsg(lvlError, format("warning: the group %1% specified in build-users-group does not exist")
printError(format("warning: the group %1% specified in build-users-group does not exist")
% settings.buildUsersGroup);
else {
struct stat st;
@ -136,7 +136,7 @@ LocalStore::LocalStore(const Params & params)
globalLock = openLockFile(globalLockPath.c_str(), true);
if (!lockFile(globalLock.get(), ltRead, false)) {
printMsg(lvlError, "waiting for the big Nix store lock...");
printError("waiting for the big Nix store lock...");
lockFile(globalLock.get(), ltRead, true);
}
@ -167,7 +167,7 @@ LocalStore::LocalStore(const Params & params)
"please upgrade Nix to version 1.11 first.");
if (!lockFile(globalLock.get(), ltWrite, false)) {
printMsg(lvlError, "waiting for exclusive access to the Nix store...");
printError("waiting for exclusive access to the Nix store...");
lockFile(globalLock.get(), ltWrite, true);
}
@ -1108,7 +1108,7 @@ void LocalStore::invalidatePathChecked(const Path & path)
bool LocalStore::verifyStore(bool checkContents, bool repair)
{
printMsg(lvlError, format("reading the Nix store..."));
printError(format("reading the Nix store..."));
bool errors = false;
@ -1119,7 +1119,7 @@ bool LocalStore::verifyStore(bool checkContents, bool repair)
for (auto & i : readDirectory(realStoreDir)) store.insert(i.name);
/* Check whether all valid paths actually exist. */
printMsg(lvlInfo, "checking path existence...");
printInfo("checking path existence...");
PathSet validPaths2 = queryAllValidPaths(), validPaths, done;
@ -1132,7 +1132,7 @@ bool LocalStore::verifyStore(bool checkContents, bool repair)
/* Optionally, check the content hashes (slow). */
if (checkContents) {
printMsg(lvlInfo, "checking hashes...");
printInfo("checking hashes...");
Hash nullHash(htSHA256);
@ -1145,7 +1145,7 @@ bool LocalStore::verifyStore(bool checkContents, bool repair)
HashResult current = hashPath(info->narHash.type, i);
if (info->narHash != nullHash && info->narHash != current.first) {
printMsg(lvlError, format("path %1% was modified! "
printError(format("path %1% was modified! "
"expected hash %2%, got %3%")
% i % printHash(info->narHash) % printHash(current.first));
if (repair) repairPath(i); else errors = true;
@ -1155,14 +1155,14 @@ bool LocalStore::verifyStore(bool checkContents, bool repair)
/* Fill in missing hashes. */
if (info->narHash == nullHash) {
printMsg(lvlError, format("fixing missing hash on %1%") % i);
printError(format("fixing missing hash on %1%") % i);
info->narHash = current.first;
update = true;
}
/* Fill in missing narSize fields (from old stores). */
if (info->narSize == 0) {
printMsg(lvlError, format("updating size field on %1% to %2%") % i % current.second);
printError(format("updating size field on %1% to %2%") % i % current.second);
info->narSize = current.second;
update = true;
}
@ -1178,9 +1178,9 @@ bool LocalStore::verifyStore(bool checkContents, bool repair)
/* It's possible that the path got GC'ed, so ignore
errors on invalid paths. */
if (isValidPath(i))
printMsg(lvlError, format("error: %1%") % e.msg());
printError(format("error: %1%") % e.msg());
else
printMsg(lvlError, format("warning: %1%") % e.msg());
printError(format("warning: %1%") % e.msg());
errors = true;
}
}
@ -1199,7 +1199,7 @@ void LocalStore::verifyPath(const Path & path, const PathSet & store,
done.insert(path);
if (!isStorePath(path)) {
printMsg(lvlError, format("path %1% is not in the Nix store") % path);
printError(format("path %1% is not in the Nix store") % path);
auto state(_state.lock());
invalidatePath(*state, path);
return;
@ -1218,16 +1218,16 @@ void LocalStore::verifyPath(const Path & path, const PathSet & store,
}
if (canInvalidate) {
printMsg(lvlError, format("path %1% disappeared, removing from database...") % path);
printError(format("path %1% disappeared, removing from database...") % path);
auto state(_state.lock());
invalidatePath(*state, path);
} else {
printMsg(lvlError, format("path %1% disappeared, but it still has valid referrers!") % path);
printError(format("path %1% disappeared, but it still has valid referrers!") % path);
if (repair)
try {
repairPath(path);
} catch (Error & e) {
printMsg(lvlError, format("warning: %1%") % e.msg());
printError(format("warning: %1%") % e.msg());
errors = true;
}
else errors = true;
@ -1279,7 +1279,7 @@ static void makeMutable(const Path & path)
void LocalStore::upgradeStore7()
{
if (getuid() != 0) return;
printMsg(lvlError, "removing immutable bits from the Nix store (this may take a while)...");
printError("removing immutable bits from the Nix store (this may take a while)...");
makeMutable(realStoreDir);
}

View file

@ -43,7 +43,7 @@ struct MakeReadOnly
LocalStore::InodeHash LocalStore::loadInodeHash()
{
printMsg(lvlDebug, "loading hash inodes in memory");
debug("loading hash inodes in memory");
InodeHash inodeHash;
AutoCloseDir dir = opendir(linksDir.c_str());
@ -75,7 +75,7 @@ Strings LocalStore::readDirectoryIgnoringInodes(const Path & path, const InodeHa
checkInterrupt();
if (inodeHash.count(dirent->d_ino)) {
printMsg(lvlDebug, format("%1% is already linked") % dirent->d_name);
debug(format("%1% is already linked") % dirent->d_name);
continue;
}
@ -116,13 +116,13 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
NixOS (example: $fontconfig/var/cache being modified). Skip
those files. FIXME: check the modification time. */
if (S_ISREG(st.st_mode) && (st.st_mode & S_IWUSR)) {
printMsg(lvlError, format("skipping suspicious writable file %1%") % path);
printError(format("skipping suspicious writable file %1%") % path);
return;
}
/* This can still happen on top-level files. */
if (st.st_nlink > 1 && inodeHash.count(st.st_ino)) {
printMsg(lvlDebug, format("%1% is already linked, with %2% other file(s)") % path % (st.st_nlink - 2));
debug(format("%1% is already linked, with %2% other file(s)") % path % (st.st_nlink - 2));
return;
}
@ -136,7 +136,7 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
contents of the symlink (i.e. the result of readlink()), not
the contents of the target (which may not even exist). */
Hash hash = hashPath(htSHA256, path).first;
printMsg(lvlDebug, format("%1% has hash %2%") % path % printHash(hash));
debug(format("%1% has hash %2%") % path % printHash(hash));
/* Check if this is a known hash. */
Path linkPath = linksDir + "/" + printHash32(hash);
@ -161,12 +161,12 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
throw SysError(format("getting attributes of path %1%") % linkPath);
if (st.st_ino == stLink.st_ino) {
printMsg(lvlDebug, format("%1% is already linked to %2%") % path % linkPath);
debug(format("%1% is already linked to %2%") % path % linkPath);
return;
}
if (st.st_size != stLink.st_size) {
printMsg(lvlError, format("removing corrupted link %1%") % linkPath);
printError(format("removing corrupted link %1%") % linkPath);
unlink(linkPath.c_str());
goto retry;
}
@ -192,7 +192,7 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
systems). This is likely to happen with empty files.
Just shrug and ignore. */
if (st.st_size)
printMsg(lvlInfo, format("%1% has maximum number of links") % linkPath);
printInfo(format("%1% has maximum number of links") % linkPath);
return;
}
throw SysError(format("cannot link %1% to %2%") % tempLink % linkPath);
@ -201,14 +201,14 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
/* Atomically replace the old file with the new hard link. */
if (rename(tempLink.c_str(), path.c_str()) == -1) {
if (unlink(tempLink.c_str()) == -1)
printMsg(lvlError, format("unable to unlink %1%") % tempLink);
printError(format("unable to unlink %1%") % tempLink);
if (errno == EMLINK) {
/* Some filesystems generate too many links on the rename,
rather than on the original link. (Probably it
temporarily increases the st_nlink field before
decreasing it again.) */
if (st.st_size)
printMsg(lvlInfo, format("%1% has maximum number of links") % linkPath);
printInfo(format("%1% has maximum number of links") % linkPath);
return;
}
throw SysError(format("cannot rename %1% to %2%") % tempLink % path);
@ -244,7 +244,7 @@ void LocalStore::optimiseStore()
optimiseStore(stats);
printMsg(lvlError,
printError(
format("%1% freed by hard-linking %2% files")
% showBytes(stats.bytesFreed)
% stats.filesLinked);

View file

@ -121,7 +121,7 @@ bool PathLocks::lockPaths(const PathSet & _paths,
/* Acquire an exclusive lock. */
if (!lockFile(fd.get(), ltWrite, false)) {
if (wait) {
if (waitMsg != "") printMsg(lvlError, waitMsg);
if (waitMsg != "") printError(waitMsg);
lockFile(fd.get(), ltWrite, true);
} else {
/* Failed to lock this path; release all other
@ -174,7 +174,7 @@ void PathLocks::unlock()
lockedPaths.erase(i.second);
if (close(i.first) == -1)
printMsg(lvlError,
printError(
format("error (ignored): cannot close lock file on %1%") % i.second);
debug(format("lock released on %1%") % i.second);

View file

@ -132,9 +132,9 @@ void deleteGeneration(const Path & profile, unsigned int gen)
static void deleteGeneration2(const Path & profile, unsigned int gen, bool dryRun)
{
if (dryRun)
printMsg(lvlInfo, format("would remove generation %1%") % gen);
printInfo(format("would remove generation %1%") % gen);
else {
printMsg(lvlInfo, format("removing generation %1%") % gen);
printInfo(format("removing generation %1%") % gen);
deleteGeneration(profile, gen);
}
}

View file

@ -559,7 +559,7 @@ void RemoteStore::Connection::processStderr(Sink * sink, Source * source)
to.flush();
}
else
printMsg(lvlError, chomp(readString(from)));
printError(chomp(readString(from)));
}
if (msg == STDERR_ERROR) {
string error = readString(from);

View file

@ -161,7 +161,7 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
printMsg(lvlInfo, format("uploaded s3://%1%/%2% (%3% bytes) in %4% ms")
printInfo(format("uploaded s3://%1%/%2% (%3% bytes) in %4% ms")
% bucketName % path % data.size() % duration);
stats.putTimeMs += duration;

View file

@ -10,11 +10,11 @@ namespace nix {
int err = sqlite3_errcode(db);
if (err == SQLITE_BUSY || err == SQLITE_PROTOCOL) {
if (err == SQLITE_PROTOCOL)
printMsg(lvlError, "warning: SQLite database is busy (SQLITE_PROTOCOL)");
printError("warning: SQLite database is busy (SQLITE_PROTOCOL)");
else {
static bool warned = false;
if (!warned) {
printMsg(lvlError, "warning: SQLite database is busy");
printError("warning: SQLite database is busy");
warned = true;
}
}

View file

@ -472,7 +472,7 @@ void ValidPathInfo::sign(const SecretKey & secretKey)
bool ValidPathInfo::isContentAddressed(const Store & store) const
{
auto warn = [&]() {
printMsg(lvlError, format("warning: path %s claims to be content-addressed but isn't") % path);
printError(format("warning: path %s claims to be content-addressed but isn't") % path);
};
if (hasPrefix(ca, "text:")) {