1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

libstore: Fix double-quoting of paths in logs

std::filesystem::path is already quoted by boost::format with double quotes (").
(cherry picked from commit f30cb8667b)
This commit is contained in:
Sergei Zimmerman 2025-10-10 23:57:36 +03:00 committed by github-actions[bot]
parent 70655061e3
commit 634e1d3b65
2 changed files with 9 additions and 9 deletions

View file

@ -1383,7 +1383,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
for (auto & link : DirectoryIterator{linksDir}) { for (auto & link : DirectoryIterator{linksDir}) {
checkInterrupt(); checkInterrupt();
auto name = link.path().filename(); auto name = link.path().filename();
printMsg(lvlTalkative, "checking contents of '%s'", name); printMsg(lvlTalkative, "checking contents of %s", name);
PosixSourceAccessor accessor; PosixSourceAccessor accessor;
std::string hash = hashPath( std::string hash = hashPath(
PosixSourceAccessor::createAtRoot(link.path()), PosixSourceAccessor::createAtRoot(link.path()),
@ -1391,10 +1391,10 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
HashAlgorithm::SHA256) HashAlgorithm::SHA256)
.first.to_string(HashFormat::Nix32, false); .first.to_string(HashFormat::Nix32, false);
if (hash != name.string()) { if (hash != name.string()) {
printError("link '%s' was modified! expected hash '%s', got '%s'", link.path(), name, hash); printError("link %s was modified! expected hash %s, got '%s'", link.path(), name, hash);
if (repair) { if (repair) {
std::filesystem::remove(link.path()); std::filesystem::remove(link.path());
printInfo("removed link '%s'", link.path()); printInfo("removed link %s", link.path());
} else { } else {
errors = true; errors = true;
} }

View file

@ -202,7 +202,7 @@ void LocalStore::optimisePath_(
full. When that happens, it's fine to ignore it: we full. When that happens, it's fine to ignore it: we
just effectively disable deduplication of this just effectively disable deduplication of this
file. */ file. */
printInfo("cannot link '%s' to '%s': %s", linkPath, path, strerror(errno)); printInfo("cannot link %s to '%s': %s", linkPath, path, strerror(errno));
return; return;
} }
@ -216,11 +216,11 @@ void LocalStore::optimisePath_(
auto stLink = lstat(linkPath.string()); auto stLink = lstat(linkPath.string());
if (st.st_ino == stLink.st_ino) { if (st.st_ino == stLink.st_ino) {
debug("'%1%' is already linked to '%2%'", path, linkPath); debug("'%1%' is already linked to %2%", path, linkPath);
return; return;
} }
printMsg(lvlTalkative, "linking '%1%' to '%2%'", path, linkPath); printMsg(lvlTalkative, "linking '%1%' to %2%", path, linkPath);
/* Make the containing directory writable, but only if it's not /* Make the containing directory writable, but only if it's not
the store itself (we don't want or need to mess with its the store itself (we don't want or need to mess with its
@ -245,7 +245,7 @@ void LocalStore::optimisePath_(
systems). This is likely to happen with empty files. systems). This is likely to happen with empty files.
Just shrug and ignore. */ Just shrug and ignore. */
if (st.st_size) if (st.st_size)
printInfo("'%1%' has maximum number of links", linkPath); printInfo("%1% has maximum number of links", linkPath);
return; return;
} }
throw; throw;
@ -256,13 +256,13 @@ void LocalStore::optimisePath_(
std::filesystem::rename(tempLink, path); std::filesystem::rename(tempLink, path);
} catch (std::filesystem::filesystem_error & e) { } catch (std::filesystem::filesystem_error & e) {
std::filesystem::remove(tempLink); std::filesystem::remove(tempLink);
printError("unable to unlink '%1%'", tempLink); printError("unable to unlink %1%", tempLink);
if (e.code() == std::errc::too_many_links) { if (e.code() == std::errc::too_many_links) {
/* Some filesystems generate too many links on the rename, /* Some filesystems generate too many links on the rename,
rather than on the original link. (Probably it rather than on the original link. (Probably it
temporarily increases the st_nlink field before temporarily increases the st_nlink field before
decreasing it again.) */ decreasing it again.) */
debug("'%s' has reached maximum number of links", linkPath); debug("%s has reached maximum number of links", linkPath);
return; return;
} }
throw; throw;