mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-19 09:36:47 +02:00
fix: handle errors in nix::createDirs
the `std::filesystem::create_directories` can fail due to insufficient permissions. We convert this error into a `SysError` and catch it wherever required.
This commit is contained in:
parent
857e380c7d
commit
85b7989764
3 changed files with 8 additions and 4 deletions
|
@ -107,8 +107,8 @@ ReadlineLikeInteracter::Guard ReadlineLikeInteracter::init(detail::ReplCompleter
|
||||||
rl_readline_name = "nix-repl";
|
rl_readline_name = "nix-repl";
|
||||||
try {
|
try {
|
||||||
createDirs(dirOf(historyFile));
|
createDirs(dirOf(historyFile));
|
||||||
} catch (std::filesystem::filesystem_error & e) {
|
} catch (SystemError & e) {
|
||||||
warn(e.what());
|
logWarning(e.info());
|
||||||
}
|
}
|
||||||
#ifndef USE_READLINE
|
#ifndef USE_READLINE
|
||||||
el_hist_size = 1000;
|
el_hist_size = 1000;
|
||||||
|
|
|
@ -1304,7 +1304,7 @@ ref<Store> openStore(StoreReference && storeURI)
|
||||||
if (!pathExists(chrootStore)) {
|
if (!pathExists(chrootStore)) {
|
||||||
try {
|
try {
|
||||||
createDirs(chrootStore);
|
createDirs(chrootStore);
|
||||||
} catch (std::filesystem::filesystem_error & e) {
|
} catch (SystemError & e) {
|
||||||
return std::make_shared<LocalStore>(params);
|
return std::make_shared<LocalStore>(params);
|
||||||
}
|
}
|
||||||
warn("'%s' does not exist, so Nix will use '%s' as a chroot store", stateDir, chrootStore);
|
warn("'%s' does not exist, so Nix will use '%s' as a chroot store", stateDir, chrootStore);
|
||||||
|
|
|
@ -415,7 +415,11 @@ void deletePath(const fs::path & path)
|
||||||
|
|
||||||
void createDirs(const Path & path)
|
void createDirs(const Path & path)
|
||||||
{
|
{
|
||||||
fs::create_directories(path);
|
try {
|
||||||
|
fs::create_directories(path);
|
||||||
|
} catch (fs::filesystem_error & e) {
|
||||||
|
throw SysError("creating directory '%1%'", path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue