The check filebase command now also removes dead symlinks from the download directories

This commit is contained in:
Michiel Broek 2007-02-11 13:43:22 +00:00
parent 15caf2d63c
commit 5135e4c135
2 changed files with 16 additions and 2 deletions

View File

@ -5,6 +5,11 @@ v0.91.3 11-Feb-2007
mbuser: mbuser:
Set default editor on erased records. Set default editor on erased records.
mbfile:
The check filebase command now also removes dead symlinks from
the download directories.
v0.91.2 14-Jan-2007 - 11-Feb-2007 v0.91.2 14-Jan-2007 - 11-Feb-2007

View File

@ -4,7 +4,7 @@
* Purpose: File Database Maintenance - Check filebase * Purpose: File Database Maintenance - Check filebase
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2007
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -533,7 +533,7 @@ void CheckArea(int Area)
(strncmp(de->d_name, "index", 5)) && (strncmp(de->d_name, "index", 5)) &&
(strncmp(de->d_name, "readme", 6))) { (strncmp(de->d_name, "readme", 6))) {
snprintf(fn, PATH_MAX, "%s/%s", area.Path, de->d_name); snprintf(fn, PATH_MAX, "%s/%s", area.Path, de->d_name);
if (stat(fn, &stb) == 0) if (stat(fn, &stb) == 0) {
if (S_ISREG(stb.st_mode)) { if (S_ISREG(stb.st_mode)) {
if (unlink(fn) == 0) { if (unlink(fn) == 0) {
Syslog('!', "%s not in fdb, deleted from disk", fn); Syslog('!', "%s not in fdb, deleted from disk", fn);
@ -542,6 +542,15 @@ void CheckArea(int Area)
WriteError("$%s not in fdb, cannot delete", fn); WriteError("$%s not in fdb, cannot delete", fn);
} }
} }
}
if (lstat(fn, &stb) == 0) {
if (unlink(fn) == 0) {
Syslog('-', "%s dead link removed from disk", fn);
iErrors++;
} else {
WriteError("$%s link not in fdb, cannot delete", fn);
}
}
} }
} }
} }