Fixed a bug in mbfile pack/kill

This commit is contained in:
Michiel Broek 2003-03-13 19:27:48 +00:00
parent 94e0f7d7e1
commit f5a9861ead
2 changed files with 199 additions and 194 deletions

View File

@ -17,6 +17,13 @@ v0.37.2 23-Feb-2003.
mbfido:
Finding the inbound tic file now uses the new function.
mbfile:
When a file was deleted for age or download age, the 8.3
filename was not removed from disk.
A better check againts empty upload dates when purging files.
Also added a log when this happens. Please report if you see
any of these.
examples:
Removed the last menu item from the offline menu, added new
Extended Info toggle (English only).

View File

@ -58,13 +58,10 @@ extern int do_pack; /* Perform pack */
void Kill(void)
{
FILE *pAreas, *pFile, *pDest, *pTemp;
int i, iAreas, iAreasNew = 0;
int iTotal = 0, iKilled = 0, iMoved = 0;
char *sAreas, *fAreas, *newdir = NULL, *sTemp;
int i, iAreas, iAreasNew = 0, iTotal = 0, iKilled = 0, iMoved = 0, rc, Killit, FilesLeft;
char *sAreas, *fAreas, *newdir = NULL, *sTemp, from[PATH_MAX], to[PATH_MAX];
time_t Now;
int rc, Killit, FilesLeft;
struct fileareas darea;
char from[PATH_MAX], to[PATH_MAX];
sAreas = calloc(PATH_MAX, sizeof(char));
fAreas = calloc(PATH_MAX, sizeof(char));
@ -104,8 +101,7 @@ void Kill(void)
}
/*
* Check if download directory exists,
* if not, create the directory.
* Check if download directory exists, if not, create the directory.
*/
if (access(area.Path, R_OK) == -1) {
Syslog('!', "Create dir: %s", area.Path);
@ -139,17 +135,18 @@ void Kill(void)
Marker();
Killit = FALSE;
if (!file.UploadDate)
Syslog('!', "Warning: file %s in area %d has no upload date", file.Name, i);
if (area.DLdays) {
/*
* Test last download date or never downloaded and the
* file is more then n days available for download.
*/
if ((file.LastDL) &&
(((Now - file.LastDL) / 84400) > area.DLdays)) {
if ((file.LastDL) && (((Now - file.LastDL) / 84400) > area.DLdays)) {
Killit = TRUE;
}
if ((!file.LastDL) &&
(((Now - file.UploadDate) / 84400) > area.DLdays)) {
if ((!file.LastDL) && file.UploadDate && (((Now - file.UploadDate) / 84400) > area.DLdays)) {
Killit = TRUE;
}
}
@ -158,7 +155,7 @@ void Kill(void)
/*
* Check filedate
*/
if (((Now - file.UploadDate) / 84400) > area.FDdays) {
if (file.UploadDate && (((Now - file.UploadDate) / 84400) > area.FDdays)) {
Killit = TRUE;
}
}
@ -206,8 +203,7 @@ void Kill(void)
fwrite(&file, sizeof(file), 1, pFile);
iMoved++;
} else {
WriteError("Move %s to area %d failed, %s",
file.Name, area.MoveArea, strerror(rc));
WriteError("Move %s to area %d failed, %s", file.Name, area.MoveArea, strerror(rc));
}
} else {
Syslog('+', "Delete %s, area %d", file.LName, i);
@ -217,6 +213,8 @@ void Kill(void)
iKilled++;
sprintf(from, "%s/%s", area.Path, file.LName);
unlink(from);
sprintf(from, "%s/%s", area.Path, file.Name);
unlink(from);
}
}
}