Fixed mbfile kill bug and dup announce bug

This commit is contained in:
Michiel Broek 2004-03-11 18:58:51 +00:00
parent 66fb5827e8
commit a15239d0ff
8 changed files with 49 additions and 12 deletions

View File

@ -3,6 +3,7 @@ $Id$
If you feel lucky then try this version, if not just wait If you feel lucky then try this version, if not just wait
a few days so that I fix the destructive bugs that might a few days so that I fix the destructive bugs that might
be present in this version. be present in this version.
One found, destroyed 5 fileareas, don't think it won't happen!
v0.51.2 06-Mar-2004 v0.51.2 06-Mar-2004
@ -34,6 +35,11 @@ v0.51.2 06-Mar-2004
files, thumbnails are now also removed from disk. files, thumbnails are now also removed from disk.
Updated tic file import function to the new files database Updated tic file import function to the new files database
structure. 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: mbfile:
Updated kill, index, check, pack, list, adopt, import, move, Updated kill, index, check, pack, list, adopt, import, move,

4
TODO
View File

@ -125,6 +125,10 @@ mbfido:
N: Reimplement characterset conversion again on the gateway. 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: mbcico:
N: Further investigate binkp tty_error hangup. N: Further investigate binkp tty_error hangup.

View File

@ -129,7 +129,7 @@ void Uploads()
} }
T_File.TotLdesc = k; T_File.TotLdesc = k;
T_File.Announce = TRUE; T_File.Announce = TRUE;
if (Add_ToBeRep()) if (Add_ToBeRep(T_File))
Count++; Count++;
/* /*
* Mark file is announced. * Mark file is announced.

View File

@ -229,7 +229,7 @@ void Kill(void)
* Now we must pack this area database otherwise * Now we must pack this area database otherwise
* we run into trouble later on. * 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")); sprintf(sTemp, "%s/fdb/filetmp.data", getenv("MBSE_ROOT"));
if ((pTemp = fopen(sTemp, "a+")) != NULL) { if ((pTemp = fopen(sTemp, "a+")) != NULL) {

View File

@ -677,7 +677,7 @@ int ProcessTic(fa_list *sbl)
strncpy(T_File.Name, TIC.NewFile, 12); strncpy(T_File.Name, TIC.NewFile, 12);
strncpy(T_File.LName, TIC.NewFullName, 80); strncpy(T_File.LName, TIC.NewFullName, 80);
T_File.Fdate = TIC.FileDate; T_File.Fdate = TIC.FileDate;
Add_ToBeRep(); Add_ToBeRep(T_File);
} }
if (TIC.SendOrg && !tic.FileArea) { if (TIC.SendOrg && !tic.FileArea) {

View File

@ -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. * The newfiles announce option will later remove these records.
*/ */
int Add_ToBeRep() int Add_ToBeRep(struct _filerecord report)
{ {
char *fname; char *fname;
struct _filerecord Temp; struct _filerecord Temp;
@ -56,8 +57,30 @@ int Add_ToBeRep()
fseek(tbr, 0, SEEK_SET); fseek(tbr, 0, SEEK_SET);
while (fread(&Temp, sizeof(Temp), 1, tbr) == 1) { 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; Found = TRUE;
}
} }
if (Found) { if (Found) {
@ -66,6 +89,10 @@ int Add_ToBeRep()
return FALSE; return FALSE;
} }
/*
* Append record
*/
Syslog('f', "Add_ToBeRep append record");
fwrite(&T_File, sizeof(T_File), 1, tbr); fwrite(&T_File, sizeof(T_File), 1, tbr);
fclose(tbr); fclose(tbr);
return TRUE; return TRUE;

View File

@ -3,6 +3,6 @@
/* $Id$ */ /* $Id$ */
int Add_ToBeRep(void); int Add_ToBeRep(struct _filerecord);
#endif #endif

View File

@ -428,17 +428,17 @@ int main(int argc, char *argv[])
oldmask = umask(002); oldmask = umask(002);
if ((argc == 2) && (strncmp(tl(argv[1]), "i", 1) == 0))
init = TRUE;
else
screen_start((char *)"MBsetup");
do_quiet = TRUE; do_quiet = TRUE;
Syslog(' ', " "); Syslog(' ', " ");
Syslog(' ', "MBSETUP v%s started by %s", VERSION, pw->pw_name); Syslog(' ', "MBSETUP v%s started by %s", VERSION, pw->pw_name);
if (init) if (init)
Syslog('+', "Cmd: mbsetup 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")) { if (lockprogram((char *)"mbsetup")) {
printf("\n\7Another mbsetup is already running, abort.\n\n"); printf("\n\7Another mbsetup is already running, abort.\n\n");
die(MBERR_NO_PROGLOCK); die(MBERR_NO_PROGLOCK);