diff options
author | julia <midnight@trainwit.ch> | 2024-05-18 15:38:33 +1000 |
---|---|---|
committer | julia <midnight@trainwit.ch> | 2024-06-16 03:53:00 +0000 |
commit | 0fa289f559708407ab4384739c0f24258c114b44 (patch) | |
tree | 33a4268a8a6951ee7bb816a9537413a051d1d752 /src/libstore/remote-store.cc | |
parent | 4734ce7831daf6e7e976029017b1cc2e7e615f30 (diff) |
Harmonise the Store::queryPathInfoUncached interface
This:
- Consistently returns `nullptr` for a non-existent
store path, instead of a mix of `nullptr` and
throwing exceptions.
- If a store returns "bad" store paths in response
to a request (e.g. incorrect hash or name), don't
cache this result. This removes some duplication
of code at the cache-access layer of queryPathInfo()
checking this, and allows us to provide more
specific errors.
Part of #270.
Change-Id: I86612c6499b1a37ab872c712c2304d6a3ff19edb
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r-- | src/libstore/remote-store.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 93b1afabd..966dd3fe0 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -309,14 +309,14 @@ std::shared_ptr<const ValidPathInfo> RemoteStore::queryPathInfoUncached(const St try { conn.processStderr(); } catch (Error & e) { - // Ugly backwards compatibility hack. + // Ugly backwards compatibility hack. TODO(fj#325): remove. if (e.msg().find("is not valid") != std::string::npos) - throw InvalidPath(std::move(e.info())); + return nullptr; throw; } if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 17) { bool valid; conn->from >> valid; - if (!valid) throw InvalidPath("path '%s' is not valid", printStorePath(path)); + if (!valid) return nullptr; } return std::make_shared<ValidPathInfo>( StorePath{path}, |