libstore/store-api: isValidPath inform the user about physical store locations

Instead of showing logical Nix store paths, we show the actual physical
location so that the user can stat by copy-pasting these paths.

The bad thing about this change is that certain Nix porcelain only
accept their logical counterparts.

Change-Id: Id0eb45d1bf08a23508dfc2bb694c88155654f585
Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
Raito Bezarius
2025-07-26 20:52:25 +00:00
parent b7a9da96be
commit bde5830352
+10 -3
View File
@@ -674,7 +674,9 @@ try {
if (res && res->isKnownNow()) {
stats.narInfoReadAverted++;
if (!res->didExist())
throw InvalidPath("path '%s' does not exist in the store", printStorePath(storePath));
throw InvalidPath(
"path '%s' does not exist in the store", toRealPath(printStorePath(storePath))
);
co_return ref<const ValidPathInfo>::unsafeFromPtr(res->value);
}
}
@@ -688,7 +690,10 @@ try {
state_->pathInfoCache.upsert(std::string(storePath.to_string()),
res.first == NarInfoDiskCache::oInvalid ? PathInfoCacheValue{} : PathInfoCacheValue{ .value = res.second });
if (res.first == NarInfoDiskCache::oInvalid)
throw InvalidPath("path '%s' does not exist in the store", printStorePath(storePath));
throw InvalidPath(
"path '%s' does not exist in the store",
toRealPath(printStorePath(storePath))
);
}
co_return ref<const ValidPathInfo>::unsafeFromPtr(res.second);
}
@@ -711,7 +716,9 @@ try {
if (!info) {
stats.narInfoMissing++;
throw InvalidPath("path '%s' does not exist in the store", printStorePath(storePath));
throw InvalidPath(
"path '%s' does not exist in the store", toRealPath(printStorePath(storePath))
);
}
co_return ref<const ValidPathInfo>::unsafeFromPtr(info);