Skip to content

Commit

Permalink
Follow symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
layus committed Jun 9, 2022
1 parent baee9fe commit 44d5bd4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/libfetchers/zip-input-accessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,19 @@ struct ZipInputAccessor : InputAccessor

std::string readFile(const CanonPath & path) override
{
if (lstat(path).type != tRegular)
throw Error("file '%s' is not a regular file", path);
auto type = lstat(path).type;

if (type == tRegular)
return _readFile(path);

if (type == tSymlink) {
auto parent = path.parent();
if (parent.has_value())
return readFile(parent.value() + CanonPath(readLink(path)));
}

throw Error("file '%s' is not a regular file", path);

return _readFile(path);
}

bool pathExists(const CanonPath & path) override
Expand Down

0 comments on commit 44d5bd4

Please sign in to comment.