aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/path.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-02-28 18:07:10 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-02-28 18:07:10 +0100
commit22a754c091f765061f59bef5ce091268493bb138 (patch)
treee0e12a576a01307ecb97fa043497ca2840a3a3e6 /src/libstore/path.cc
parent2e953b567ebbcd3aaaf71bf592ab733bdcdd6797 (diff)
Fix GC failures on bad store path names
It failed on names like '/nix/store/9ip48nkc9rfy0a4yaw98lp6gipqlib1a-'.
Diffstat (limited to 'src/libstore/path.cc')
-rw-r--r--src/libstore/path.cc14
1 files changed, 14 insertions, 0 deletions
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<StorePath> 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;