From e261f5072e07b4275ca64c38d3d24e1f2d6738a8 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 5 Mar 2004 19:27:09 +0000 Subject: [PATCH] Fixed duplicate newfiles bug --- ChangeLog | 2 ++ TODO | 4 ---- lib/Makefile | 2 ++ mbfido/Makefile | 4 ++-- mbfido/announce.c | 40 +----------------------------------- mbfido/toberep.c | 52 +++++++++++++++++++++++------------------------ mbfido/toberep.h | 5 ++--- 7 files changed, 35 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c493d58..fa955e0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -79,6 +79,8 @@ v0.51.1 21-Feb-2004 now case insensitive, also the area tagnames are forced to uppercase. This should solve the problems with Linuxnet. Replaced system() call with execute. + New files with already in the toberep database will not be + added again. mbdiff: Replaced system() call with execute. diff --git a/TODO b/TODO index c9e81dc4..37e66f6c 100644 --- a/TODO +++ b/TODO @@ -121,10 +121,6 @@ mbfido: N: After readalias we need to free the alias list when mbfido ends. - N: When a file with the same name is received in a tic area more than - once (virus defs for example) the file is written multiple times - in the toberep database and will be multiple times announced. - N: Reimplement characterset conversion again on the gateway. mbcico: diff --git a/lib/Makefile b/lib/Makefile index 5714878b..311d025f 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -131,6 +131,7 @@ client.o: ../config.h mbselib.h crc.o: ../config.h mbselib.h semafore.o: ../config.h mbselib.h signame.o: ../config.h mbselib.h +charset.o: ../config.h mbselib.h attach.o: ../config.h mbselib.h falists.o: ../config.h mbselib.h hdr.o: ../config.h mbselib.h @@ -178,5 +179,6 @@ smtp.o: ../config.h mbselib.h mbinet.h diesel.o: ../config.h mbselib.h diesel.h mbdiesel.o: ../config.h mbselib.h diesel.h nodelist.o: ../config.h mbselib.h nodelist.h +mbcharsetc.o: ../config.h mbselib.h mbcharsetc.h ftscprod.o: ../config.h mbselib.h # End of generated dependencies diff --git a/mbfido/Makefile b/mbfido/Makefile index 255531ce..df2308fc 100644 --- a/mbfido/Makefile +++ b/mbfido/Makefile @@ -35,7 +35,7 @@ MBFIDO_OBJS = flock.o tosspkt.o mbfido.o hatch.o maketags.o virscan.o tracker.o postecho.o backalias.o createm.o createf.o msgflags.o dirsession.o \ queue.o dirlock.o qualify.o MBSEQ_OBJS = mbseq.o -MBAFF_OBJS = announce.o fflist.o filefind.o grlist.o mbaff.o msgutil.o +MBAFF_OBJS = announce.o fflist.o filefind.o grlist.o mbaff.o msgutil.o toberep.o MBINDEX_OBJS = mbindex.o MBDIFF_OBJS = mbdiff.o MBFILE_OBJS = mbfile.o mbfkill.o mbfutil.o mbfindex.o mbfcheck.o mbfpack.o mbflist.o mbfadopt.o \ @@ -153,7 +153,7 @@ post.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h ../lib/msg.h rnews.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbinet.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h rfc2ftn.h mbfido.h ../paths.h rnews.h storenet.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h msgflags.h rollover.h storenet.h utic.o: ../config.h ../lib/mbselib.h tic.h mover.h tic.h utic.h -announce.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h ../lib/diesel.h grlist.h msgutil.h announce.h +announce.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h ../lib/diesel.h grlist.h msgutil.h toberep.h announce.h fflist.o: ../config.h ../lib/mbselib.h ../lib/msg.h fflist.h ftn2rfc.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h rollover.h aliasdb.h postemail.h backalias.h msgflags.h ftn2rfc.h makestat.o: ../config.h ../lib/mbselib.h ../lib/diesel.h ../lib/msg.h mgrutil.h makestat.h diff --git a/mbfido/announce.c b/mbfido/announce.c index 17e1c74a..b895a6f4 100644 --- a/mbfido/announce.c +++ b/mbfido/announce.c @@ -37,6 +37,7 @@ #include "../lib/diesel.h" #include "grlist.h" #include "msgutil.h" +#include "toberep.h" #include "announce.h" @@ -48,45 +49,6 @@ int MsgCount; /* Message counter */ -/* - * Add a file whos data is in T_File to the toberep.data file. - */ -int Add_ToBeRep(void); -int Add_ToBeRep() -{ - char *fname; - struct _filerecord Temp; - FILE *tbr; - int Found = FALSE; - - fname = calloc(PATH_MAX, sizeof(char)); - sprintf(fname, "%s/etc/toberep.data", getenv("MBSE_ROOT")); - if ((tbr = fopen(fname, "a+")) == NULL) { - WriteError("$Can't create %s", fname); - free(fname); - return FALSE; - } - free(fname); - - 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)) - Found = TRUE; - } - - if (Found) { - Syslog('!', "File %s already in toberep.data", T_File.Name); - fclose(tbr); - return FALSE; - } - - fwrite(&T_File, sizeof(T_File), 1, tbr); - fclose(tbr); - return TRUE; -} - - - /* * Check for uploads, these are files in the files database with * the announced flag not yet set. diff --git a/mbfido/toberep.c b/mbfido/toberep.c index 78ce99d2..88e03b89 100644 --- a/mbfido/toberep.c +++ b/mbfido/toberep.c @@ -31,8 +31,6 @@ #include "../config.h" #include "../lib/mbselib.h" #include "tic.h" - - #include "toberep.h" @@ -40,35 +38,37 @@ * Add a file whos data is in T_File to the toberep.data file. * The newfiles announce option will later remove these records. */ -void Add_ToBeRep() +int Add_ToBeRep() { - char fname[128]; - struct _filerecord Temp; - FILE *tbr; - int Found = FALSE; + char *fname; + struct _filerecord Temp; + FILE *tbr; + int Found = FALSE; - sprintf(fname, "%s/etc/toberep.data", getenv("MBSE_ROOT")); - if ((tbr = fopen(fname, "a+")) == NULL) { - WriteError("$Can't create %s", fname); - return; - } + fname = calloc(PATH_MAX, sizeof(char)); + sprintf(fname, "%s/etc/toberep.data", getenv("MBSE_ROOT")); + if ((tbr = fopen(fname, "a+")) == NULL) { + WriteError("$Can't create %s", fname); + free(fname); + return FALSE; + } + free(fname); - 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) && - (strcmp(Temp.Echo, T_File.Echo) == 0)) - Found = TRUE; - } + 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)) + Found = TRUE; + } - if (Found) { - Syslog('!', "File %s already in toberep.data", T_File.Name); - fclose(tbr); - return; - } - - fwrite(&T_File, sizeof(T_File), 1, tbr); + if (Found) { + Syslog('!', "File %s already in toberep.data", T_File.Name); fclose(tbr); + return FALSE; + } + + fwrite(&T_File, sizeof(T_File), 1, tbr); + fclose(tbr); + return TRUE; } diff --git a/mbfido/toberep.h b/mbfido/toberep.h index e5f3cac7..fd9bd834 100644 --- a/mbfido/toberep.h +++ b/mbfido/toberep.h @@ -1,9 +1,8 @@ #ifndef _TOBEREP_H #define _TOBEREP_H +/* $Id$ */ -void Add_ToBeRep(void); - +int Add_ToBeRep(void); #endif -