From 5773d667ee26efb4b977b9109da509d46d8378b5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 14 Nov 2017 14:49:06 +0100 Subject: [PATCH] nix ls-{nar,store}: Don't abort on missing files --- src/libstore/nar-accessor.cc | 2 +- tests/nar-access.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstore/nar-accessor.cc b/src/libstore/nar-accessor.cc index e5042208e..839a7991c 100644 --- a/src/libstore/nar-accessor.cc +++ b/src/libstore/nar-accessor.cc @@ -214,7 +214,7 @@ void listNar(JSONPlaceholder & res, ref accessor, obj.attr("target", accessor->readLink(path)); break; default: - abort(); + throw Error("path '%s' does not exist in NAR", path); } } diff --git a/tests/nar-access.sh b/tests/nar-access.sh index 63f97f36c..e29e4689b 100644 --- a/tests/nar-access.sh +++ b/tests/nar-access.sh @@ -32,3 +32,7 @@ diff -u baz.cat-nar $storePath/foo/baz [[ $(nix ls-store --json $storePath) = '{"type":"directory","entries":{"foo":{},"foo-x":{},"qux":{},"zyx":{}}}' ]] [[ $(nix ls-store --json -R $storePath/foo) = '{"type":"directory","entries":{"bar":{"type":"regular","size":0},"baz":{"type":"regular","size":0},"data":{"type":"regular","size":58}}}' ]] [[ $(nix ls-store --json -R $storePath/foo/bar) = '{"type":"regular","size":0}' ]] + +# Test missing files. +nix ls-store --json -R $storePath/xyzzy 2>&1 | grep 'does not exist in NAR' +nix ls-store $storePath/xyzzy 2>&1 | grep 'does not exist'