Skip to content

Commit

Permalink
Avoid trailing slash that broke lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Oct 7, 2024
1 parent ceb8b48 commit 750275d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/hydra-queue-runner/nar-extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,29 @@ struct Extractor : FileSystemObjectSink
};

NarMemberDatas & members;
Path prefix;
std::filesystem::path prefix;

Path toKey(const CanonPath & path)
{
std::filesystem::path p = prefix;
// Conditional to avoid trailing slash
if (!path.isRoot()) p /= path.rel();
return p;
}

Extractor(NarMemberDatas & members, const Path & prefix)
: members(members), prefix(prefix)
{ }

void createDirectory(const CanonPath & path) override
{
members.insert_or_assign(prefix + path.abs(), NarMemberData { .type = SourceAccessor::Type::tDirectory });
members.insert_or_assign(toKey(path), NarMemberData { .type = SourceAccessor::Type::tDirectory });
}

void createRegularFile(const CanonPath & path, std::function<void(CreateRegularFileSink &)> func) override
{
NarMemberConstructor nmc {
members.insert_or_assign(prefix + path.abs(), NarMemberData {
members.insert_or_assign(toKey(path), NarMemberData {
.type = SourceAccessor::Type::tRegular,
.fileSize = 0,
.contents = filesToKeep.count(path.abs()) ? std::optional("") : std::nullopt,
Expand All @@ -79,7 +87,7 @@ struct Extractor : FileSystemObjectSink

void createSymlink(const CanonPath & path, const std::string & target) override
{
members.insert_or_assign(prefix + path.abs(), NarMemberData { .type = SourceAccessor::Type::tSymlink });
members.insert_or_assign(toKey(path), NarMemberData { .type = SourceAccessor::Type::tSymlink });
}
};

Expand Down

0 comments on commit 750275d

Please sign in to comment.