Skip to content
Snippets Groups Projects
Commit 7c9d0a59 authored by Eelco Dolstra's avatar Eelco Dolstra
Browse files

nix-collect-garbage: Handle ENOENT

Don't barf trying to read a link that just got deleted.

Fixes #575.
parent 5845ffdf
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,12 @@ void removeOldGenerations(std::string dir) ...@@ -28,7 +28,12 @@ void removeOldGenerations(std::string dir)
auto type = i.type == DT_UNKNOWN ? getFileType(path) : i.type; auto type = i.type == DT_UNKNOWN ? getFileType(path) : i.type;
if (type == DT_LNK && canWrite) { if (type == DT_LNK && canWrite) {
auto link = readLink(path); std::string link;
try {
link = readLink(path);
} catch (SysError & e) {
if (e.errNo == ENOENT) continue;
}
if (link.find("link") != string::npos) { if (link.find("link") != string::npos) {
printMsg(lvlInfo, format("removing old generations of profile %1%") % path); printMsg(lvlInfo, format("removing old generations of profile %1%") % path);
if (deleteOlderThan != "") if (deleteOlderThan != "")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment