diff options
author | Efraim Flashner <efraim@flashner.co.il> | 2021-12-19 15:15:11 +0200 |
---|---|---|
committer | Efraim Flashner <efraim@flashner.co.il> | 2021-12-19 15:15:11 +0200 |
commit | 6ccf8ea81f95963c0b7f945648106576008ee105 (patch) | |
tree | f39f596e6c3e98ff1e9f1de0ad41c977e9dd37c1 /nix/libutil | |
parent | fcaed5b81e893f34d77527fbef389ca628ca882d (diff) | |
parent | 9f916d14765b00309c742fcbff0cfabdd10dcf05 (diff) |
Merge branch 'master' into core-updates
Diffstat (limited to 'nix/libutil')
-rw-r--r-- | nix/libutil/util.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index 69f1c634a9..4d3780e3c2 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc @@ -337,12 +337,15 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed, size for (auto & i : readDirectory(path)) _deletePath(path + "/" + i.name, bytesFreed, linkThreshold); } + + int ret; + ret = S_ISDIR(st.st_mode) ? rmdir(path.c_str()) : unlink(path.c_str()); + if (ret == -1) + throw SysError(format("cannot unlink `%1%'") % path); + #undef st_mode #undef st_size #undef st_nlink - - if (remove(path.c_str()) == -1) - throw SysError(format("cannot unlink `%1%'") % path); } |