1
0
Fork 0
forked from lix-project/lix

Merge pull request from squalus/nar-close-file

archive: check close errors when extracting nars
This commit is contained in:
Eelco Dolstra 2022-09-30 12:58:28 +02:00 committed by GitHub
commit 89ca75c9f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View file

@ -75,6 +75,9 @@ struct NarAccessor : public FSAccessor
createMember(path, {FSAccessor::Type::tRegular, false, 0, 0}); createMember(path, {FSAccessor::Type::tRegular, false, 0, 0});
} }
void closeRegularFile() override
{ }
void isExecutable() override void isExecutable() override
{ {
parents.top()->isExecutable = true; parents.top()->isExecutable = true;

View file

@ -234,6 +234,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
else if (s == "contents" && type == tpRegular) { else if (s == "contents" && type == tpRegular) {
parseContents(sink, source, path); parseContents(sink, source, path);
sink.closeRegularFile();
} }
else if (s == "executable" && type == tpRegular) { else if (s == "executable" && type == tpRegular) {
@ -324,6 +325,12 @@ struct RestoreSink : ParseSink
if (!fd) throw SysError("creating file '%1%'", p); if (!fd) throw SysError("creating file '%1%'", p);
} }
void closeRegularFile() override
{
/* Call close explicitly to make sure the error is checked */
fd.close();
}
void isExecutable() override void isExecutable() override
{ {
struct stat st; struct stat st;

View file

@ -60,6 +60,7 @@ struct ParseSink
virtual void createDirectory(const Path & path) { }; virtual void createDirectory(const Path & path) { };
virtual void createRegularFile(const Path & path) { }; virtual void createRegularFile(const Path & path) { };
virtual void closeRegularFile() { };
virtual void isExecutable() { }; virtual void isExecutable() { };
virtual void preallocateContents(uint64_t size) { }; virtual void preallocateContents(uint64_t size) { };
virtual void receiveContents(std::string_view data) { }; virtual void receiveContents(std::string_view data) { };