forked from lix-project/lix
7080321618
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.
40 lines
921 B
C++
40 lines
921 B
C++
#pragma once
|
|
|
|
#include "fs-accessor.hh"
|
|
#include "ref.hh"
|
|
#include "store-api.hh"
|
|
|
|
namespace nix {
|
|
|
|
class RemoteFSAccessor : public FSAccessor
|
|
{
|
|
ref<Store> store;
|
|
|
|
std::map<std::string, ref<FSAccessor>> nars;
|
|
|
|
Path cacheDir;
|
|
|
|
std::pair<ref<FSAccessor>, Path> fetch(const Path & path_, bool requireValidPath = true);
|
|
|
|
friend class BinaryCacheStore;
|
|
|
|
Path makeCacheFile(std::string_view hashPart, const std::string & ext);
|
|
|
|
void addToCache(std::string_view hashPart, const std::string & nar,
|
|
ref<FSAccessor> narAccessor);
|
|
|
|
public:
|
|
|
|
RemoteFSAccessor(ref<Store> store,
|
|
const /* FIXME: use std::optional */ Path & cacheDir = "");
|
|
|
|
Stat stat(const Path & path) override;
|
|
|
|
StringSet readDirectory(const Path & path) override;
|
|
|
|
std::string readFile(const Path & path, bool requireValidPath = true) override;
|
|
|
|
std::string readLink(const Path & path) override;
|
|
};
|
|
|
|
}
|