mirror of
https://github.com/NixOS/nix.git
synced 2025-12-03 07:31:00 +01:00
libstore: Actually correctly call remove in case rename fails
(cherry picked from commit 1cc337bb5f)
This commit is contained in:
parent
6c4dc93d9b
commit
3e50cadbe6
1 changed files with 6 additions and 2 deletions
|
|
@ -255,8 +255,12 @@ void LocalStore::optimisePath_(
|
||||||
try {
|
try {
|
||||||
std::filesystem::rename(tempLink, path);
|
std::filesystem::rename(tempLink, path);
|
||||||
} catch (std::filesystem::filesystem_error & e) {
|
} catch (std::filesystem::filesystem_error & e) {
|
||||||
std::filesystem::remove(tempLink);
|
{
|
||||||
printError("unable to unlink %1%", tempLink);
|
std::error_code ec;
|
||||||
|
remove(tempLink, ec); /* Clean up after ourselves. */
|
||||||
|
if (ec)
|
||||||
|
printError("unable to unlink %1%: %2%", tempLink, ec.message());
|
||||||
|
}
|
||||||
if (e.code() == std::errc::too_many_links) {
|
if (e.code() == std::errc::too_many_links) {
|
||||||
/* Some filesystems generate too many links on the rename,
|
/* Some filesystems generate too many links on the rename,
|
||||||
rather than on the original link. (Probably it
|
rather than on the original link. (Probably it
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue