LocalStore::addToStore(): Ignore exceptions from parseDump()

In the "discard" case (i.e. when the store path already exists
locally), when we call parseDump() from a Finally and it throws an
exception (e.g. if the download of the NAR fails), Nix crashes:

   terminate called after throwing an instance of 'nix::SubstituteGone'
     what():  error: file 'nar/06br3254rx4gz4cvjzxlv028jrx80zg5i4jr62vjmn416dqihgr7.nar.xz' does not exist in binary cache 'http://localhost'
   Aborted (core dumped)
This commit is contained in:
Eelco Dolstra 2024-01-18 17:01:45 +01:00
parent ab786e22f1
commit a18d8d688a

View file

@ -1049,7 +1049,11 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
Finally cleanup = [&]() {
if (!narRead) {
NullParseSink sink;
try {
parseDump(sink, source);
} catch (...) {
ignoreException();
}
}
};