nix-collect-garbage: Handle ENOENT

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

Fixes #575.
This commit is contained in:
Eelco Dolstra 2015-07-17 11:24:25 +02:00
parent 5845ffdf13
commit 7c9d0a5969

View file

@ -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 != "")