From 820c9bdaf57e4a40f76c3ebc7413cdcdeb857ca7 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 1 Mar 2025 23:55:42 +0100 Subject: [PATCH] libstore: don't abort when flat-importing non-files fixes #705 Change-Id: I3be20235006425dd3bb6156510d021699f05b9ba --- lix/libstore/store-api.cc | 4 ++-- tests/functional/add.sh | 6 ++++++ tests/functional/symlink | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) create mode 120000 tests/functional/symlink diff --git a/lix/libstore/store-api.cc b/lix/libstore/store-api.cc index 910451a84..53d9b1117 100644 --- a/lix/libstore/store-api.cc +++ b/lix/libstore/store-api.cc @@ -401,12 +401,12 @@ struct RetrieveRegularNARVisitor : NARParseVisitor box_ptr createDirectory(const std::string & name) override { - assert(false && "RetrieveRegularNARVisitor::createDirectory must not be called"); + throw Error("cannot import directory using flat ingestion"); } void createSymlink(const std::string & name, const std::string & target) override { - assert(false && "RetrieveRegularNARVisitor::createSymlink must not be called"); + throw Error("cannot import symlink using flat ingestion"); } }; } diff --git a/tests/functional/add.sh b/tests/functional/add.sh index 5c3eed793..38ce9d2d9 100644 --- a/tests/functional/add.sh +++ b/tests/functional/add.sh @@ -1,5 +1,11 @@ source common.sh +expectStderr 1 nix-store --add-fixed sha256 . | grep "cannot import directory using flat ingestion" +expectStderr 1 nix-store --add-fixed sha256 ./symlink | grep "cannot import symlink using flat ingestion" + +expectStderr 1 nix-store --add-fixed sha1 . | grep "cannot import directory using flat ingestion" +expectStderr 1 nix-store --add-fixed sha1 ./symlink | grep "cannot import symlink using flat ingestion" + path1=$(nix-store --add ./dummy) echo $path1 diff --git a/tests/functional/symlink b/tests/functional/symlink new file mode 120000 index 000000000..429f42921 --- /dev/null +++ b/tests/functional/symlink @@ -0,0 +1 @@ +add.sh \ No newline at end of file