diff options
author | regnat <rg@regnat.ovh> | 2020-12-15 10:54:24 +0100 |
---|---|---|
committer | regnat <rg@regnat.ovh> | 2020-12-15 20:10:46 +0100 |
commit | 7080321618e29033a8b5dc2f9fc938dcf2df270d (patch) | |
tree | d950e9e64bfa798c23fce3a881f805e7470cae81 /src/libstore/remote-fs-accessor.cc | |
parent | f2f60bf5d6c95453f89e47e01fe0bd6a7fdc85bb (diff) |
Use the fs accessor for readInvalidDerivation
Extend `FSAccessor::readFile` to allow not checking that the path is a
valid one, and rewrite `readInvalidDerivation` using this extended
`readFile`.
Several places in the code use `readInvalidDerivation`, either because
they need to read a derivation that has been written in the store but
not registered yet, or more generally to prevent a deadlock because
`readDerivation` tries to lock the state, so can't be called from a
place where the lock is already held.
However, `readInvalidDerivation` implicitely assumes that the store is a
`LocalFSStore`, which isn't always the case.
The concrete motivation for this is that it's required for `nix copy
--from someBinaryCache` to work, which is tremendously useful for the
tests.
Diffstat (limited to 'src/libstore/remote-fs-accessor.cc')
-rw-r--r-- | src/libstore/remote-fs-accessor.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstore/remote-fs-accessor.cc b/src/libstore/remote-fs-accessor.cc index 63bde92de..f43456f0b 100644 --- a/src/libstore/remote-fs-accessor.cc +++ b/src/libstore/remote-fs-accessor.cc @@ -43,13 +43,13 @@ void RemoteFSAccessor::addToCache(std::string_view hashPart, const std::string & } } -std::pair<ref<FSAccessor>, Path> RemoteFSAccessor::fetch(const Path & path_) +std::pair<ref<FSAccessor>, Path> RemoteFSAccessor::fetch(const Path & path_, bool requireValidPath) { auto path = canonPath(path_); auto [storePath, restPath] = store->toStorePath(path); - if (!store->isValidPath(storePath)) + if (requireValidPath && !store->isValidPath(storePath)) throw InvalidPath("path '%1%' is not a valid store path", store->printStorePath(storePath)); auto i = nars.find(std::string(storePath.hashPart())); @@ -113,9 +113,9 @@ StringSet RemoteFSAccessor::readDirectory(const Path & path) return res.first->readDirectory(res.second); } -std::string RemoteFSAccessor::readFile(const Path & path) +std::string RemoteFSAccessor::readFile(const Path & path, bool requireValidPath) { - auto res = fetch(path); + auto res = fetch(path, requireValidPath); return res.first->readFile(res.second); } |