mbfile checks now double filerecords

This commit is contained in:
Michiel Broek 2002-02-08 12:27:15 +00:00
parent dfaee3d490
commit 7195d79c86
4 changed files with 33 additions and 13 deletions

View File

@ -4514,7 +4514,7 @@ v0.33.19 26-Oct-2001
linewrap. Experimental. linewrap. Experimental.
mbfile: 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. Implemented "mbfile adopt" function.
Started working on long filename support. The real name on Started working on long filename support. The real name on
disk is the long filename, the database records also holds disk is the long filename, the database records also holds
@ -4544,6 +4544,8 @@ v0.33.19 26-Oct-2001
filebases. filebases.
Added standard doctype header and commentline to the html Added standard doctype header and commentline to the html
pages. pages.
The mbfile check function deletes double filerecords in the
database.
mball: mball:
The index function is now obsolete, this is added to mbfile. The index function is now obsolete, this is added to mbfile.

View File

@ -424,6 +424,7 @@ struct FILERecord {
unsigned Missing : 1; /* Missing */ unsigned Missing : 1; /* Missing */
unsigned NoKill : 1; /* Cannot be deleted */ unsigned NoKill : 1; /* Cannot be deleted */
unsigned Announced : 1; /* File is announced */ unsigned Announced : 1; /* File is announced */
unsigned Double : 1; /* Double record */
}; };

View File

@ -204,8 +204,21 @@ void Check(void)
rewind(pFile); rewind(pFile);
while (fread(&file, sizeof(file), 1, pFile) == 1) { while (fread(&file, sizeof(file), 1, pFile) == 1) {
if (strcmp(file.LName, de->d_name) == 0) { if (strcmp(file.LName, de->d_name) == 0) {
if (!Found) {
Found = TRUE; 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) && if ((!Found) &&

View File

@ -112,20 +112,24 @@ void PackFileBase(void)
iTotal++; iTotal++;
if ((!file.Deleted) && (strcmp(file.Name, "") != 0)) { if ((!file.Deleted) && (!file.Double) && (strcmp(file.Name, "") != 0)) {
fwrite(&file, sizeof(file), 1, fp); fwrite(&file, sizeof(file), 1, fp);
} else { } else {
iRemoved++; iRemoved++;
Syslog('+', "Removed file \"%s\" from area %d", file.LName, i); if (file.Double) {
sprintf(fn, "%s/%s", area.Path, file.LName); Syslog('+', "Removed double record file \"%s\" from area %d", file.LName, i);
rc = unlink(fn); } else {
if (rc) Syslog('+', "Removed file \"%s\" from area %d", file.LName, i);
Syslog('+', "Unlink %s failed, result %d", fn, rc); sprintf(fn, "%s/%s", area.Path, file.LName);
/* rc = unlink(fn);
* If a dotted version (thumbnail) exists, remove it silently if (rc)
*/ Syslog('+', "Unlink %s failed, result %d", fn, rc);
sprintf(fn, "%s/.%s", area.Path, file.LName); /*
unlink(fn); * If a dotted version (thumbnail) exists, remove it silently
*/
sprintf(fn, "%s/.%s", area.Path, file.LName);
unlink(fn);
}
do_index = TRUE; do_index = TRUE;
} }
} }