From 7195d79c86f4d69ac8dd19332d9e865bbe7b0c45 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 8 Feb 2002 12:27:15 +0000 Subject: [PATCH] mbfile checks now double filerecords --- ChangeLog | 4 +++- lib/structs.h | 1 + mbfido/mbfcheck.c | 15 ++++++++++++++- mbfido/mbfpack.c | 26 +++++++++++++++----------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec1a7141..07a2e4a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4514,7 +4514,7 @@ v0.33.19 26-Oct-2001 linewrap. Experimental. mbfile: - During check the file databases are reset to filemode 0660. + During checks the file databases are reset to filemode 0660. Implemented "mbfile adopt" function. Started working on long filename support. The real name on disk is the long filename, the database records also holds @@ -4544,6 +4544,8 @@ v0.33.19 26-Oct-2001 filebases. Added standard doctype header and commentline to the html pages. + The mbfile check function deletes double filerecords in the + database. mball: The index function is now obsolete, this is added to mbfile. diff --git a/lib/structs.h b/lib/structs.h index 3a40cf05..46ad5357 100644 --- a/lib/structs.h +++ b/lib/structs.h @@ -424,6 +424,7 @@ struct FILERecord { unsigned Missing : 1; /* Missing */ unsigned NoKill : 1; /* Cannot be deleted */ unsigned Announced : 1; /* File is announced */ + unsigned Double : 1; /* Double record */ }; diff --git a/mbfido/mbfcheck.c b/mbfido/mbfcheck.c index d5946dc5..9abe449f 100644 --- a/mbfido/mbfcheck.c +++ b/mbfido/mbfcheck.c @@ -204,8 +204,21 @@ void Check(void) rewind(pFile); while (fread(&file, sizeof(file), 1, pFile) == 1) { if (strcmp(file.LName, de->d_name) == 0) { + if (!Found) { Found = TRUE; - break; + } else { + /* + * Record has been found before, so this must be + * a double record. + */ + Syslog('!', "Double file record area %d file %s", + i, file.LName); + iErrors++; + file.Double = TRUE; + do_pack = TRUE; + fseek(pFile, - sizeof(file), SEEK_CUR); + fwrite(&file, sizeof(file), 1, pFile); + } } } if ((!Found) && diff --git a/mbfido/mbfpack.c b/mbfido/mbfpack.c index ad91ccab..a48304a1 100644 --- a/mbfido/mbfpack.c +++ b/mbfido/mbfpack.c @@ -112,20 +112,24 @@ void PackFileBase(void) iTotal++; - if ((!file.Deleted) && (strcmp(file.Name, "") != 0)) { + if ((!file.Deleted) && (!file.Double) && (strcmp(file.Name, "") != 0)) { fwrite(&file, sizeof(file), 1, fp); } else { iRemoved++; - Syslog('+', "Removed file \"%s\" from area %d", file.LName, i); - sprintf(fn, "%s/%s", area.Path, file.LName); - rc = unlink(fn); - if (rc) - Syslog('+', "Unlink %s failed, result %d", fn, rc); - /* - * If a dotted version (thumbnail) exists, remove it silently - */ - sprintf(fn, "%s/.%s", area.Path, file.LName); - unlink(fn); + if (file.Double) { + Syslog('+', "Removed double record file \"%s\" from area %d", file.LName, i); + } else { + Syslog('+', "Removed file \"%s\" from area %d", file.LName, i); + sprintf(fn, "%s/%s", area.Path, file.LName); + rc = unlink(fn); + if (rc) + Syslog('+', "Unlink %s failed, result %d", fn, rc); + /* + * If a dotted version (thumbnail) exists, remove it silently + */ + sprintf(fn, "%s/.%s", area.Path, file.LName); + unlink(fn); + } do_index = TRUE; } }