diff --git a/ChangeLog b/ChangeLog index f948b65b..09342673 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ $Id$ If you feel lucky then try this version, if not just wait a few days so that I fix the destructive bugs that might be present in this version. + One found, destroyed 5 fileareas, don't think it won't happen! v0.51.2 06-Mar-2004 @@ -34,6 +35,11 @@ v0.51.2 06-Mar-2004 files, thumbnails are now also removed from disk. Updated tic file import function to the new files database structure. + Added more checks and logging for adding new file announce + records. Newer files will replace the older record so the last + one will be announced. + Fixed a bug in mbfile kill that destroyed the filebase when a + file was deleted or moved. mbfile: Updated kill, index, check, pack, list, adopt, import, move, diff --git a/TODO b/TODO index 2aa1517c..26a8d283 100644 --- a/TODO +++ b/TODO @@ -125,6 +125,10 @@ mbfido: N: Reimplement characterset conversion again on the gateway. + N: When adding a record to the toberep database add check for existing + older entry to update the info with the later received file. Else + just handle the record as a dupe. + mbcico: N: Further investigate binkp tty_error hangup. diff --git a/mbfido/announce.c b/mbfido/announce.c index 1575816f..abc8d58c 100644 --- a/mbfido/announce.c +++ b/mbfido/announce.c @@ -129,7 +129,7 @@ void Uploads() } T_File.TotLdesc = k; T_File.Announce = TRUE; - if (Add_ToBeRep()) + if (Add_ToBeRep(T_File)) Count++; /* * Mark file is announced. diff --git a/mbfido/mbfkill.c b/mbfido/mbfkill.c index 98ba8b20..18a8becd 100644 --- a/mbfido/mbfkill.c +++ b/mbfido/mbfkill.c @@ -229,7 +229,7 @@ void Kill(void) * Now we must pack this area database otherwise * we run into trouble later on. */ - fseek(pFile, 0, SEEK_SET); + fseek(pFile, fdbhdr.hdrsize, SEEK_SET); sprintf(sTemp, "%s/fdb/filetmp.data", getenv("MBSE_ROOT")); if ((pTemp = fopen(sTemp, "a+")) != NULL) { diff --git a/mbfido/ptic.c b/mbfido/ptic.c index e8b9a3f2..a42071a2 100644 --- a/mbfido/ptic.c +++ b/mbfido/ptic.c @@ -677,7 +677,7 @@ int ProcessTic(fa_list *sbl) strncpy(T_File.Name, TIC.NewFile, 12); strncpy(T_File.LName, TIC.NewFullName, 80); T_File.Fdate = TIC.FileDate; - Add_ToBeRep(); + Add_ToBeRep(T_File); } if (TIC.SendOrg && !tic.FileArea) { diff --git a/mbfido/toberep.c b/mbfido/toberep.c index 88e03b89..3f6930d7 100644 --- a/mbfido/toberep.c +++ b/mbfido/toberep.c @@ -35,10 +35,11 @@ /* - * Add a file whos data is in T_File to the toberep.data file. + * Add a file record to the toberep database and do some checks. + * The function returns TRUE if the file will be announced. * The newfiles announce option will later remove these records. */ -int Add_ToBeRep() +int Add_ToBeRep(struct _filerecord report) { char *fname; struct _filerecord Temp; @@ -56,8 +57,30 @@ int Add_ToBeRep() fseek(tbr, 0, SEEK_SET); while (fread(&Temp, sizeof(Temp), 1, tbr) == 1) { - if ((strcmp(Temp.Name, T_File.Name) == 0) && (Temp.Fdate == T_File.Fdate)) + + if (strcmp(Temp.Name, report.Name) == 0) { + Syslog('f', "Add_ToBeRep found record with the same name"); + if (strlen(report.Echo) && (strcmp(Temp.Echo, report.Echo) == 0)) { + Syslog('f', "Add_ToBeRep this is the same tic area"); + /* + * If it's a later received file, update the record + */ + if (report.Fdate > Temp.Fdate) { + Syslog('f', "Add_ToBeRep this file is newer, update record"); + fseek(tbr, - sizeof(Temp), SEEK_SET); + fwrite(&report, sizeof(report), 1, tbr); + fclose(tbr); + return TRUE; + } + Syslog('f', "Add_ToBeRep this file is older, discard record"); + fclose(tbr); + return TRUE; + } + } + if ((strcmp(Temp.Name, report.Name) == 0) && (Temp.Fdate == T_File.Fdate)) { + Syslog('f', "Add_ToBeRep record with same filename, but other area"); Found = TRUE; + } } if (Found) { @@ -66,6 +89,10 @@ int Add_ToBeRep() return FALSE; } + /* + * Append record + */ + Syslog('f', "Add_ToBeRep append record"); fwrite(&T_File, sizeof(T_File), 1, tbr); fclose(tbr); return TRUE; diff --git a/mbfido/toberep.h b/mbfido/toberep.h index fd9bd834..d6bf225e 100644 --- a/mbfido/toberep.h +++ b/mbfido/toberep.h @@ -3,6 +3,6 @@ /* $Id$ */ -int Add_ToBeRep(void); +int Add_ToBeRep(struct _filerecord); #endif diff --git a/mbsetup/mbsetup.c b/mbsetup/mbsetup.c index 52e09c7d..76cb3559 100644 --- a/mbsetup/mbsetup.c +++ b/mbsetup/mbsetup.c @@ -428,17 +428,17 @@ int main(int argc, char *argv[]) oldmask = umask(002); - if ((argc == 2) && (strncmp(tl(argv[1]), "i", 1) == 0)) - init = TRUE; - else - screen_start((char *)"MBsetup"); - do_quiet = TRUE; Syslog(' ', " "); Syslog(' ', "MBSETUP v%s started by %s", VERSION, pw->pw_name); if (init) Syslog('+', "Cmd: mbsetup init"); + if ((argc == 2) && (strncmp(tl(argv[1]), "i", 1) == 0)) + init = TRUE; + else + screen_start((char *)"MBsetup"); + if (lockprogram((char *)"mbsetup")) { printf("\n\7Another mbsetup is already running, abort.\n\n"); die(MBERR_NO_PROGLOCK);