diff --git a/lix/libstore/binary-cache-store.cc b/lix/libstore/binary-cache-store.cc index 1a67ec27e..3cab26714 100644 --- a/lix/libstore/binary-cache-store.cc +++ b/lix/libstore/binary-cache-store.cc @@ -178,7 +178,19 @@ try { {"root", listNar(narIndex)}, }; - upsertFile(std::string(info.path.hashPart()) + ".ls", j.dump(), "application/json"); + try { + upsertFile(std::string(info.path.hashPart()) + ".ls", j.dump(), "application/json"); + } catch (ForeignException & exc) { + if (exc.is()) { + warn( + "Skipping NAR listing for path '%1%' due to serialization failure: %2%", + printStorePath(narInfo->path), + exc.what() + ); + } else { + throw exc; + } + } } /* Optionally maintain an index of DWARF debug info files diff --git a/tests/functional/nar-access.nix b/tests/functional/nar-access.nix index 9948abe59..6756291b4 100644 --- a/tests/functional/nar-access.nix +++ b/tests/functional/nar-access.nix @@ -1,3 +1,4 @@ +{ nonUtf8Inodes ? false }: with import ./config.nix; rec { @@ -13,6 +14,8 @@ rec { touch $out/qux mkdir $out/zyx + ${if nonUtf8Inodes then ''printf "data" > "$out/invalid-\x80file"'' else ""} + cat >$out/foo/data <