Added more dupes database debug logging
This commit is contained in:
parent
92d5e5464b
commit
7e1b714687
17
lib/dbdupe.c
17
lib/dbdupe.c
@ -5,7 +5,7 @@
|
|||||||
* Last modification date : 25-May-2001
|
* Last modification date : 25-May-2001
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2001
|
* Copyright (C) 1997-2002
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -57,6 +57,7 @@ void InitDupes()
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
Syslog('n', "Init Dupes");
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
dupes[i].crcs= NULL;
|
dupes[i].crcs= NULL;
|
||||||
dupes[i].loaded = FALSE;
|
dupes[i].loaded = FALSE;
|
||||||
@ -96,7 +97,7 @@ int CheckDupe(unsigned long crc, int idx, int max)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reserve some extra memeory and record howmuch.
|
* Reserve some extra memory and record howmuch.
|
||||||
*/
|
*/
|
||||||
if (size > max)
|
if (size > max)
|
||||||
dupes[idx].peak = size + 5000;
|
dupes[idx].peak = size + 5000;
|
||||||
@ -111,13 +112,14 @@ int CheckDupe(unsigned long crc, int idx, int max)
|
|||||||
dupes[idx].crcs[dupes[idx].count] = test;
|
dupes[idx].crcs[dupes[idx].count] = test;
|
||||||
dupes[idx].count++;
|
dupes[idx].count++;
|
||||||
}
|
}
|
||||||
|
Syslog('n', "Loaded %d dupe records in %s", dupes[idx].count++, files[idx]);
|
||||||
fclose(fil);
|
fclose(fil);
|
||||||
free(dfile);
|
free(dfile);
|
||||||
dupes[idx].loaded = TRUE;
|
dupes[idx].loaded = TRUE;
|
||||||
dupes[idx].max = max;
|
dupes[idx].max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
Syslog('n', "dupetest %08x %d %d", crc, idx, max);
|
Syslog('n', "dupetest %08x %s %d", crc, files[idx], max);
|
||||||
|
|
||||||
for (i = 0; i < dupes[idx].count; i++) {
|
for (i = 0; i < dupes[idx].count; i++) {
|
||||||
if (dupes[idx].crcs[i] == crc) {
|
if (dupes[idx].crcs[i] == crc) {
|
||||||
@ -129,6 +131,7 @@ int CheckDupe(unsigned long crc, int idx, int max)
|
|||||||
* Not a dupe, append new crc value
|
* Not a dupe, append new crc value
|
||||||
*/
|
*/
|
||||||
dupes[idx].crcs[dupes[idx].count] = crc;
|
dupes[idx].crcs[dupes[idx].count] = crc;
|
||||||
|
Syslog('n', "Added new dupe at %d", dupes[idx].count);
|
||||||
dupes[idx].count++;
|
dupes[idx].count++;
|
||||||
dupes[idx].changed = TRUE;
|
dupes[idx].changed = TRUE;
|
||||||
|
|
||||||
@ -149,6 +152,7 @@ void CloseDdb(int idx)
|
|||||||
FILE *fil;
|
FILE *fil;
|
||||||
|
|
||||||
dfile = calloc(PATH_MAX, sizeof(char));
|
dfile = calloc(PATH_MAX, sizeof(char));
|
||||||
|
Syslog('n', "Checking %s.dupe", files[idx]);
|
||||||
if (dupes[idx].loaded) {
|
if (dupes[idx].loaded) {
|
||||||
if (dupes[idx].changed) {
|
if (dupes[idx].changed) {
|
||||||
if (dupes[idx].count > dupes[idx].max)
|
if (dupes[idx].count > dupes[idx].max)
|
||||||
@ -157,12 +161,15 @@ void CloseDdb(int idx)
|
|||||||
start = 0;
|
start = 0;
|
||||||
sprintf(dfile, "%s/etc/%s.dupe", getenv("MBSE_ROOT"), files[idx]);
|
sprintf(dfile, "%s/etc/%s.dupe", getenv("MBSE_ROOT"), files[idx]);
|
||||||
if ((fil = fopen(dfile, "w"))) {
|
if ((fil = fopen(dfile, "w"))) {
|
||||||
|
Syslog('n', "Writing dupes %d to %d", start, dupes[idx].count);
|
||||||
for (j = start; j < dupes[idx].count; j++)
|
for (j = start; j < dupes[idx].count; j++)
|
||||||
fwrite(&dupes[idx].crcs[j], sizeof(unsigned long), 1, fil);
|
fwrite(&dupes[idx].crcs[j], sizeof(unsigned long), 1, fil);
|
||||||
fclose(fil);
|
fclose(fil);
|
||||||
} else {
|
} else {
|
||||||
WriteError("$Can't write %s", dfile);
|
WriteError("$Can't write %s", dfile);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Syslog('n', "Not changed so not saved");
|
||||||
}
|
}
|
||||||
|
|
||||||
dupes[idx].changed = FALSE;
|
dupes[idx].changed = FALSE;
|
||||||
@ -172,6 +179,9 @@ void CloseDdb(int idx)
|
|||||||
dupes[idx].peak = 0;
|
dupes[idx].peak = 0;
|
||||||
free(dupes[idx].crcs);
|
free(dupes[idx].crcs);
|
||||||
dupes[idx].crcs = NULL;
|
dupes[idx].crcs = NULL;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Syslog('n', "Not loaded");
|
||||||
}
|
}
|
||||||
free(dfile);
|
free(dfile);
|
||||||
}
|
}
|
||||||
@ -182,6 +192,7 @@ void CloseDupes()
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
Syslog('n', "Closing dupes databases");
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
CloseDdb(i);
|
CloseDdb(i);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user