From 08fc769d2c9d7b0b563ce2add205ff52eb94312f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 25 Feb 2022 13:19:07 +0100 Subject: [PATCH] ZipInputAccessor: Fix root directory handling --- src/libfetchers/zip-input-accessor.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libfetchers/zip-input-accessor.cc b/src/libfetchers/zip-input-accessor.cc index 3d59f902a..d8dfbb31a 100644 --- a/src/libfetchers/zip-input-accessor.cc +++ b/src/libfetchers/zip-input-accessor.cc @@ -81,13 +81,18 @@ struct ZipInputAccessor : InputAccessor bool pathExists(PathView _path) override { auto path = canonPath(_path); - return members.find(((std::string) path).c_str()) != members.end(); + return + members.find(((std::string) path).c_str()) != members.end() + || members.find(((std::string) path + "/").c_str()) != members.end(); } Stat lstat(PathView _path) override { auto path = canonPath(_path); + if (path == "/") + return Stat { .type = tDirectory }; + Type type = tRegular; bool isExecutable = false; @@ -126,7 +131,8 @@ struct ZipInputAccessor : InputAccessor DirEntries readDirectory(PathView _path) override { - auto path = canonPath(_path) + "/"; + auto path = canonPath(_path); + if (path != "/") path += "/"; auto i = members.find(((std::string) path).c_str()); if (i == members.end())