forked from lix-project/lix
Don't crash when copying realisations to a non-ca remote
Rather throw a proper exception, and catch&log it on the client side
This commit is contained in:
parent
aead35531a
commit
f67ff1f575
|
@ -165,10 +165,15 @@ bool Settings::isExperimentalFeatureEnabled(const std::string & name)
|
||||||
return std::find(f.begin(), f.end(), name) != f.end();
|
return std::find(f.begin(), f.end(), name) != f.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MissingExperimentalFeature::MissingExperimentalFeature(std::string feature)
|
||||||
|
: Error("experimental Nix feature '%1%' is disabled; use '--experimental-features %1%' to override", feature)
|
||||||
|
, missingFeature(feature)
|
||||||
|
{}
|
||||||
|
|
||||||
void Settings::requireExperimentalFeature(const std::string & name)
|
void Settings::requireExperimentalFeature(const std::string & name)
|
||||||
{
|
{
|
||||||
if (!isExperimentalFeatureEnabled(name))
|
if (!isExperimentalFeatureEnabled(name))
|
||||||
throw Error("experimental Nix feature '%1%' is disabled; use '--experimental-features %1%' to override", name);
|
throw MissingExperimentalFeature(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isWSL1()
|
bool Settings::isWSL1()
|
||||||
|
|
|
@ -45,6 +45,16 @@ struct PluginFilesSetting : public BaseSetting<Paths>
|
||||||
void set(const std::string & str, bool append = false) override;
|
void set(const std::string & str, bool append = false) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* MakeError(MissingExperimentalFeature, Error); */
|
||||||
|
class MissingExperimentalFeature: public Error
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string missingFeature;
|
||||||
|
|
||||||
|
MissingExperimentalFeature(std::string feature);
|
||||||
|
virtual const char* sname() const override { return "MissingExperimentalFeature"; }
|
||||||
|
};
|
||||||
|
|
||||||
class Settings : public Config {
|
class Settings : public Config {
|
||||||
|
|
||||||
unsigned int getDefaultCores();
|
unsigned int getDefaultCores();
|
||||||
|
@ -632,7 +642,7 @@ public:
|
||||||
is `root`.
|
is `root`.
|
||||||
|
|
||||||
> **Warning**
|
> **Warning**
|
||||||
>
|
>
|
||||||
> Adding a user to `trusted-users` is essentially equivalent to
|
> Adding a user to `trusted-users` is essentially equivalent to
|
||||||
> giving that user root access to the system. For example, the user
|
> giving that user root access to the system. For example, the user
|
||||||
> can set `sandbox-paths` and thereby obtain read access to
|
> can set `sandbox-paths` and thereby obtain read access to
|
||||||
|
@ -722,13 +732,13 @@ public:
|
||||||
The program executes with no arguments. The program's environment
|
The program executes with no arguments. The program's environment
|
||||||
contains the following environment variables:
|
contains the following environment variables:
|
||||||
|
|
||||||
- `DRV_PATH`
|
- `DRV_PATH`
|
||||||
The derivation for the built paths.
|
The derivation for the built paths.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
`/nix/store/5nihn1a7pa8b25l9zafqaqibznlvvp3f-bash-4.4-p23.drv`
|
`/nix/store/5nihn1a7pa8b25l9zafqaqibznlvvp3f-bash-4.4-p23.drv`
|
||||||
|
|
||||||
- `OUT_PATHS`
|
- `OUT_PATHS`
|
||||||
Output paths of the built derivation, separated by a space
|
Output paths of the built derivation, separated by a space
|
||||||
character.
|
character.
|
||||||
|
|
||||||
|
@ -759,7 +769,7 @@ public:
|
||||||
documentation](https://ec.haxx.se/usingcurl-netrc.html).
|
documentation](https://ec.haxx.se/usingcurl-netrc.html).
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
> This must be an absolute path, and `~` is not resolved. For
|
> This must be an absolute path, and `~` is not resolved. For
|
||||||
> example, `~/.netrc` won't resolve to your home directory's
|
> example, `~/.netrc` won't resolve to your home directory's
|
||||||
> `.netrc`.
|
> `.netrc`.
|
||||||
|
|
|
@ -655,6 +655,7 @@ void LocalStore::checkDerivationOutputs(const StorePath & drvPath, const Derivat
|
||||||
|
|
||||||
void LocalStore::registerDrvOutput(const Realisation & info)
|
void LocalStore::registerDrvOutput(const Realisation & info)
|
||||||
{
|
{
|
||||||
|
settings.requireExperimentalFeature("ca-derivations");
|
||||||
auto state(_state.lock());
|
auto state(_state.lock());
|
||||||
retrySQLite<void>([&]() {
|
retrySQLite<void>([&]() {
|
||||||
state->stmts->RegisterRealisedOutput.use()
|
state->stmts->RegisterRealisedOutput.use()
|
||||||
|
|
|
@ -794,8 +794,18 @@ std::map<StorePath, StorePath> copyPaths(ref<Store> srcStore, ref<Store> dstStor
|
||||||
realisations.insert(*realisation);
|
realisations.insert(*realisation);
|
||||||
}
|
}
|
||||||
auto pathsMap = copyPaths(srcStore, dstStore, storePaths, repair, checkSigs, substitute);
|
auto pathsMap = copyPaths(srcStore, dstStore, storePaths, repair, checkSigs, substitute);
|
||||||
for (auto& realisation : realisations) {
|
try {
|
||||||
dstStore->registerDrvOutput(realisation);
|
for (auto& realisation : realisations) {
|
||||||
|
dstStore->registerDrvOutput(realisation);
|
||||||
|
}
|
||||||
|
} catch (MissingExperimentalFeature & e) {
|
||||||
|
// Don't fail if the remote doesn't support CA derivations is it might
|
||||||
|
// not be whithin our control to change that, and we might still want
|
||||||
|
// to at least copy the output paths.
|
||||||
|
if (e.missingFeature == "ca-derivations")
|
||||||
|
ignoreException();
|
||||||
|
else
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pathsMap;
|
return pathsMap;
|
||||||
|
|
Loading…
Reference in a new issue