2016-09-02 21:24:34 +03:00
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
///@file
|
2016-09-02 21:24:34 +03:00
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
#include "source-accessor.hh"
|
2016-09-02 21:24:34 +03:00
|
|
|
#include "ref.hh"
|
|
|
|
#include "store-api.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
class RemoteFSAccessor : public SourceAccessor
|
2016-09-02 21:24:34 +03:00
|
|
|
{
|
|
|
|
ref<Store> store;
|
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
std::map<std::string, ref<SourceAccessor>> nars;
|
|
|
|
|
|
|
|
bool requireValidPath;
|
2016-09-02 21:24:34 +03:00
|
|
|
|
2017-10-17 22:15:33 +03:00
|
|
|
Path cacheDir;
|
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
std::pair<ref<SourceAccessor>, CanonPath> fetch(const CanonPath & path);
|
2017-10-17 21:51:42 +03:00
|
|
|
|
|
|
|
friend class BinaryCacheStore;
|
|
|
|
|
2020-07-13 17:19:37 +03:00
|
|
|
Path makeCacheFile(std::string_view hashPart, const std::string & ext);
|
2017-10-17 22:39:48 +03:00
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
ref<SourceAccessor> addToCache(std::string_view hashPart, std::string && nar);
|
2017-10-17 22:39:48 +03:00
|
|
|
|
2016-09-02 21:24:34 +03:00
|
|
|
public:
|
|
|
|
|
2017-10-17 22:15:33 +03:00
|
|
|
RemoteFSAccessor(ref<Store> store,
|
2023-11-01 18:09:28 +02:00
|
|
|
bool requireValidPath = true,
|
2017-10-17 22:15:33 +03:00
|
|
|
const /* FIXME: use std::optional */ Path & cacheDir = "");
|
2016-09-02 21:24:34 +03:00
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
std::optional<Stat> maybeLstat(const CanonPath & path) override;
|
2016-09-02 21:24:34 +03:00
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
DirEntries readDirectory(const CanonPath & path) override;
|
2016-09-02 21:24:34 +03:00
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
std::string readFile(const CanonPath & path) override;
|
2016-09-02 21:24:34 +03:00
|
|
|
|
2023-11-01 18:09:28 +02:00
|
|
|
std::string readLink(const CanonPath & path) override;
|
2016-09-02 21:24:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|