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: mbfido:
Finding the inbound tic file now uses the new function. 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: examples:
Removed the last menu item from the offline menu, added new Removed the last menu item from the offline menu, added new
Extended Info toggle (English only). Extended Info toggle (English only).

View File

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