Correctly call all the parent contructors of the stores

Using virtual inheritance means that only the default constructors of
the parent classes will be called, which isn't what we want
This commit is contained in:
regnat 2020-09-11 11:06:18 +02:00
parent d184ad1d27
commit 5895184df4
12 changed files with 47 additions and 20 deletions

View file

@ -2883,7 +2883,7 @@ struct RestrictedStore : public LocalFSStore
DerivationGoal & goal;
RestrictedStore(const Params & params, ref<LocalStore> next, DerivationGoal & goal)
: Store(params), LocalFSStore(params), next(next), goal(goal)
: StoreConfig(params), LocalFSStoreConfig(params), Store(params), LocalFSStore(params), next(next), goal(goal)
{ }
Path getRealStoreDir() override

View file

@ -2,17 +2,22 @@
namespace nix {
struct DummyStoreConfig : StoreConfig {};
struct DummyStoreConfig : StoreConfig {
using StoreConfig::StoreConfig;
};
struct DummyStore : public Store
struct DummyStore : public Store, public virtual DummyStoreConfig
{
DummyStore(const std::string uri, const Params & params)
: DummyStore(params)
{ }
DummyStore(const Params & params)
: Store(params)
{ }
: StoreConfig(params)
, DummyStoreConfig(params)
, Store(params)
{
}
string getUri() override
{

View file

@ -31,7 +31,9 @@ public:
HttpBinaryCacheStore(
const Path & _cacheUri,
const Params & params)
: BinaryCacheStore(params)
: StoreConfig(params)
, BinaryCacheStoreConfig(params)
, BinaryCacheStore(params)
, HttpBinaryCacheStoreConfig(params)
, cacheUri(_cacheUri)
{

View file

@ -44,7 +44,8 @@ struct LegacySSHStore : public Store, public virtual LegacySSHStoreConfig
static std::vector<std::string> uriPrefixes() { return {"ssh"}; }
LegacySSHStore(const string & host, const Params & params)
: LegacySSHStoreConfig(params)
: StoreConfig(params)
, LegacySSHStoreConfig(params)
, Store(params)
, host(host)
, connections(make_ref<Pool<Connection>>(

View file

@ -20,7 +20,9 @@ public:
LocalBinaryCacheStore(
const Path & binaryCacheDir,
const Params & params)
: LocalBinaryCacheStoreConfig(params)
: StoreConfig(params)
, BinaryCacheStoreConfig(params)
, LocalBinaryCacheStoreConfig(params)
, BinaryCacheStore(params)
, binaryCacheDir(binaryCacheDir)
{

View file

@ -42,7 +42,10 @@ namespace nix {
LocalStore::LocalStore(const Params & params)
: Store(params)
: StoreConfig(params)
, Store(params)
, LocalFSStoreConfig(params)
, LocalStoreConfig(params)
, LocalFSStore(params)
, realStoreDir_{this, false, rootDir != "" ? rootDir + "/nix/store" : storeDir, "real",
"physical path to the Nix store"}

View file

@ -30,8 +30,17 @@ struct OptimiseStats
uint64_t blocksFreed = 0;
};
struct LocalStoreConfig : virtual LocalFSStoreConfig
{
using LocalFSStoreConfig::LocalFSStoreConfig;
class LocalStore : public LocalFSStore
Setting<bool> requireSigs{(StoreConfig*) this,
settings.requireSigs,
"require-sigs", "whether store paths should have a trusted signature on import"};
};
class LocalStore : public LocalFSStore, public virtual LocalStoreConfig
{
private:
@ -95,10 +104,6 @@ public:
private:
Setting<bool> requireSigs{(StoreConfig*) this,
settings.requireSigs,
"require-sigs", "whether store paths should have a trusted signature on import"};
const PublicKeys & getPublicKeys();
public:

View file

@ -124,7 +124,10 @@ ref<RemoteStore::Connection> RemoteStore::openConnectionWrapper()
UDSRemoteStore::UDSRemoteStore(const Params & params)
: Store(params)
: StoreConfig(params)
, Store(params)
, LocalFSStoreConfig(params)
, RemoteStoreConfig(params)
, UDSRemoteStoreConfig(params)
, LocalFSStore(params)
, RemoteStore(params)

View file

@ -148,7 +148,8 @@ private:
struct UDSRemoteStoreConfig : virtual LocalFSStoreConfig, virtual RemoteStoreConfig
{
UDSRemoteStoreConfig(const Store::Params & params)
: LocalFSStoreConfig(params)
: StoreConfig(params)
, LocalFSStoreConfig(params)
, RemoteStoreConfig(params)
{
}

View file

@ -199,7 +199,9 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore, virtual S3BinaryCache
S3BinaryCacheStoreImpl(
const std::string & bucketName,
const Params & params)
: S3BinaryCacheStoreConfig(params)
: StoreConfig(params)
, BinaryCacheStoreConfig(params)
, S3BinaryCacheStoreConfig(params)
, S3BinaryCacheStore(params)
, bucketName(bucketName)
, s3Helper(profile, region, scheme, endpoint)

View file

@ -11,20 +11,23 @@ namespace nix {
struct SSHStoreConfig : virtual RemoteStoreConfig
{
using RemoteStoreConfig::RemoteStoreConfig;
const Setting<Path> sshKey{(StoreConfig*) this, "", "ssh-key", "path to an SSH private key"};
const Setting<bool> compress{(StoreConfig*) this, false, "compress", "whether to compress the connection"};
const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"};
const Setting<std::string> remoteStore{(StoreConfig*) this, "", "remote-store", "URI of the store on the remote system"};
};
class SSHStore : public RemoteStore, public virtual SSHStoreConfig
class SSHStore : public virtual RemoteStore, public virtual SSHStoreConfig
{
public:
SSHStore(const std::string & host, const Params & params)
: Store(params)
: StoreConfig(params)
, Store(params)
, RemoteStoreConfig(params)
, RemoteStore(params)
, SSHStoreConfig(params)
, host(host)
, master(
host,

View file

@ -653,7 +653,7 @@ struct LocalFSStoreConfig : virtual StoreConfig
"log", "directory where Nix will store state"};
};
class LocalFSStore : public virtual Store, public LocalFSStoreConfig
class LocalFSStore : public virtual Store, public virtual LocalFSStoreConfig
{
public: