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

@@ -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.

View File

@@ -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) {

View File

@@ -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) {

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.
*/
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;

View File

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