diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-07-23 14:56:35 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-07-23 14:56:35 +0000 |
commit | 66a2067288a86dae19aecfa9e6a5b2d37952669f (patch) | |
tree | 1ad09173a72af8b37d2439e6900983cd70e2571f /src/libstore/store-api.cc | |
parent | cdb3f39b64fa9e1d1c85bd3ba3a4b8b1c480bb2c (diff) | |
parent | 4bfba1305ed004c7b23b4e288efa707807cf2ac3 (diff) |
Merge remote-tracking branch 'upstream/master' into better-ca-parse-errors
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 80a10a2bf..5939c03b8 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -967,12 +967,20 @@ ref<Store> openStore(const std::string & uri_, throw Error("don't know how to open Nix store '%s'", uri); } +static bool isNonUriPath(const std::string & spec) { + return + // is not a URL + spec.find("://") == std::string::npos + // Has at least one path separator, and so isn't a single word that + // might be special like "auto" + && spec.find("/") != std::string::npos; +} StoreType getStoreType(const std::string & uri, const std::string & stateDir) { if (uri == "daemon") { return tDaemon; - } else if (uri == "local" || hasPrefix(uri, "/")) { + } else if (uri == "local" || isNonUriPath(uri)) { return tLocal; } else if (uri == "" || uri == "auto") { if (access(stateDir.c_str(), R_OK | W_OK) == 0) @@ -996,8 +1004,9 @@ static RegisterStoreImplementation regStore([]( return std::shared_ptr<Store>(std::make_shared<UDSRemoteStore>(params)); case tLocal: { Store::Params params2 = params; - if (hasPrefix(uri, "/")) - params2["root"] = uri; + if (isNonUriPath(uri)) { + params2["root"] = absPath(uri); + } return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2)); } default: |