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

View File

@ -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 */
};

View File

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

View File

@ -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;
}
}