From 22a754c091f765061f59bef5ce091268493bb138 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 28 Feb 2020 18:07:10 +0100 Subject: Fix GC failures on bad store path names It failed on names like '/nix/store/9ip48nkc9rfy0a4yaw98lp6gipqlib1a-'. --- src/libstore/path.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/libstore/path.cc') diff --git a/src/libstore/path.cc b/src/libstore/path.cc index a33bec3ed..70b919adc 100644 --- a/src/libstore/path.cc +++ b/src/libstore/path.cc @@ -55,6 +55,20 @@ StorePath Store::parseStorePath(std::string_view path) const return StorePath::make(path, storeDir); } +std::optional Store::maybeParseStorePath(std::string_view path) const +{ + try { + return parseStorePath(path); + } catch (Error &) { + return {}; + } +} + +bool Store::isStorePath(const Path & path) const +{ + return (bool) maybeParseStorePath(path); +} + StorePathSet Store::parseStorePathSet(const PathSet & paths) const { StorePathSet res; -- cgit v1.2.3