MountedInputAccessor, FilteringInputAccessor: Respect the path display prefix/suffix

This was causing Git paths not to be rendered correctly.
This commit is contained in:
Eelco Dolstra 2024-04-16 15:38:44 +02:00
parent 6df58a0891
commit 79363b2273
3 changed files with 7 additions and 3 deletions

View File

@ -38,7 +38,7 @@ std::string FilteringInputAccessor::readLink(const CanonPath & path)
std::string FilteringInputAccessor::showPath(const CanonPath & path)
{
return next->showPath(prefix / path);
return displayPrefix + next->showPath(prefix / path) + displaySuffix;
}
void FilteringInputAccessor::checkAccess(const CanonPath & path)

View File

@ -27,7 +27,9 @@ struct FilteringInputAccessor : InputAccessor
: next(src.accessor)
, prefix(src.path)
, makeNotAllowedError(std::move(makeNotAllowedError))
{ }
{
displayPrefix.clear();
}
std::string readFile(const CanonPath & path) override;

View File

@ -9,6 +9,8 @@ struct MountedInputAccessor : InputAccessor
MountedInputAccessor(std::map<CanonPath, ref<InputAccessor>> _mounts)
: mounts(std::move(_mounts))
{
displayPrefix.clear();
// Currently we require a root filesystem. This could be relaxed.
assert(mounts.contains(CanonPath::root));
@ -48,7 +50,7 @@ struct MountedInputAccessor : InputAccessor
std::string showPath(const CanonPath & path) override
{
auto [accessor, subpath] = resolve(path);
return accessor->showPath(subpath);
return displayPrefix + accessor->showPath(subpath) + displaySuffix;
}
std::pair<ref<InputAccessor>, CanonPath> resolve(CanonPath path)