Merge pull request #15218 from obsidiansystems/read-only-per-store
libstore: make substitution use the per-store `getReadOnly` method
This commit is contained in:
@@ -37,7 +37,7 @@ Goal::Co PathSubstitutionGoal::init()
|
||||
co_return doneSuccess(BuildResult::Success{.status = BuildResult::Success::AlreadyValid});
|
||||
}
|
||||
|
||||
if (settings.readOnlyMode)
|
||||
if (worker.store.config.getReadOnly())
|
||||
throw Error(
|
||||
"cannot substitute path '%s' - no write access to the Nix store", worker.store.printStorePath(storePath));
|
||||
|
||||
|
||||
@@ -119,6 +119,11 @@ ref<Store> DummyStoreConfig::openStore() const
|
||||
return openDummyStore();
|
||||
}
|
||||
|
||||
bool DummyStoreConfig::getReadOnly() const
|
||||
{
|
||||
return readOnly.get() || StoreConfig::getReadOnly();
|
||||
}
|
||||
|
||||
struct DummyStoreImpl : DummyStore
|
||||
{
|
||||
using Config = DummyStoreConfig;
|
||||
|
||||
@@ -35,6 +35,8 @@ struct DummyStoreConfig : public std::enable_shared_from_this<DummyStoreConfig>,
|
||||
No additional memory will be used, because no information needs to be stored.
|
||||
)"};
|
||||
|
||||
bool getReadOnly() const override;
|
||||
|
||||
static const std::string name()
|
||||
{
|
||||
return "Dummy Store";
|
||||
|
||||
@@ -117,6 +117,8 @@ public:
|
||||
> While the filesystem the database resides on might appear to be read-only, consider whether another user or system might have write access to it.
|
||||
)"};
|
||||
|
||||
bool getReadOnly() const override;
|
||||
|
||||
Setting<bool> ignoreGcDeleteFailure{
|
||||
this,
|
||||
false,
|
||||
|
||||
@@ -218,6 +218,12 @@ struct StoreConfig : public StoreConfigBase, public StoreDirConfig
|
||||
// Don't document the machine-specific default value
|
||||
false};
|
||||
|
||||
/**
|
||||
* Whether we're allowed to write to this store, also takes into account
|
||||
* global `readOnly`'s mode setting, not just any per-store settings.
|
||||
*/
|
||||
virtual bool getReadOnly() const;
|
||||
|
||||
/**
|
||||
* Open a store of the type corresponding to this configuration
|
||||
* type.
|
||||
|
||||
@@ -473,6 +473,11 @@ StoreReference LocalStoreConfig::getReference() const
|
||||
};
|
||||
}
|
||||
|
||||
bool LocalStoreConfig::getReadOnly() const
|
||||
{
|
||||
return readOnly.get() || StoreConfig::getReadOnly();
|
||||
}
|
||||
|
||||
int LocalStore::getSchema()
|
||||
{
|
||||
int curSchema = 0;
|
||||
|
||||
@@ -333,6 +333,11 @@ StoreReference StoreConfig::getReference() const
|
||||
return {.variant = StoreReference::Auto{}};
|
||||
}
|
||||
|
||||
bool StoreConfig::getReadOnly() const
|
||||
{
|
||||
return settings.readOnlyMode;
|
||||
}
|
||||
|
||||
bool Store::PathInfoCacheValue::isKnownNow()
|
||||
{
|
||||
std::chrono::duration ttl = didExist() ? std::chrono::seconds(settings.ttlPositiveNarInfoCache)
|
||||
|
||||
Reference in New Issue
Block a user