Updated mbfile rearc
This commit is contained in:
parent
e4699f2d3e
commit
9d5982b6f3
@ -52,6 +52,7 @@ void PackFileBase(void)
|
|||||||
char *sAreas, fn[PATH_MAX];
|
char *sAreas, fn[PATH_MAX];
|
||||||
#ifdef USE_EXPERIMENT
|
#ifdef USE_EXPERIMENT
|
||||||
struct _fdbarea *fdb_area = NULL;
|
struct _fdbarea *fdb_area = NULL;
|
||||||
|
int purge;
|
||||||
#else
|
#else
|
||||||
FILE *pFile, *fp;
|
FILE *pFile, *fp;
|
||||||
char *fAreas, *fTmp;
|
char *fAreas, *fTmp;
|
||||||
@ -98,6 +99,7 @@ void PackFileBase(void)
|
|||||||
#ifdef USE_EXPERIMENT
|
#ifdef USE_EXPERIMENT
|
||||||
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
purge = 0;
|
||||||
#else
|
#else
|
||||||
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
|
sprintf(fAreas, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), i);
|
||||||
sprintf(fTmp, "%s/fdb/file%d.temp", getenv("MBSE_ROOT"), i);
|
sprintf(fTmp, "%s/fdb/file%d.temp", getenv("MBSE_ROOT"), i);
|
||||||
@ -135,6 +137,9 @@ void PackFileBase(void)
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
iRemoved++;
|
iRemoved++;
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
purge++;
|
||||||
|
#endif
|
||||||
if (fdb.Double) {
|
if (fdb.Double) {
|
||||||
Syslog('+', "Removed double record file \"%s\" from area %d", fdb.LName, i);
|
Syslog('+', "Removed double record file \"%s\" from area %d", fdb.LName, i);
|
||||||
} else {
|
} else {
|
||||||
@ -158,6 +163,7 @@ void PackFileBase(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_EXPERIMENT
|
#ifdef USE_EXPERIMENT
|
||||||
|
if (purge)
|
||||||
mbsedb_PackFDB(fdb_area);
|
mbsedb_PackFDB(fdb_area);
|
||||||
mbsedb_CloseFDB(fdb_area);
|
mbsedb_CloseFDB(fdb_area);
|
||||||
#else
|
#else
|
||||||
|
@ -48,9 +48,13 @@ extern int do_index; /* Rebuild index */
|
|||||||
void ReArc(int Area, char *File)
|
void ReArc(int Area, char *File)
|
||||||
{
|
{
|
||||||
char *p, *temp, *mname, *linkpath, mask[256];
|
char *p, *temp, *mname, *linkpath, mask[256];
|
||||||
FILE *fp;
|
|
||||||
int i, rc = -1, count = 0, errors = 0;
|
int i, rc = -1, count = 0, errors = 0;
|
||||||
struct utimbuf ut;
|
struct utimbuf ut;
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
struct _fdbarea *fdb_area = NULL;
|
||||||
|
#else
|
||||||
|
FILE *fp;
|
||||||
|
#endif
|
||||||
|
|
||||||
IsDoing("ReArc file(s)");
|
IsDoing("ReArc file(s)");
|
||||||
colour(LIGHTRED, BLACK);
|
colour(LIGHTRED, BLACK);
|
||||||
@ -84,18 +88,29 @@ void ReArc(int Area, char *File)
|
|||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
if ((fdb_area = mbsedb_OpenFDB(Area, 30)) == NULL)
|
||||||
|
die(MBERR_GENERAL);
|
||||||
|
#else
|
||||||
sprintf(temp, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
sprintf(temp, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
||||||
|
|
||||||
if ((fp = fopen(temp, "r+")) == NULL)
|
if ((fp = fopen(temp, "r+")) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
||||||
|
#endif
|
||||||
|
|
||||||
colour(CYAN, BLACK);
|
colour(CYAN, BLACK);
|
||||||
strcpy(mask, re_mask(File, FALSE));
|
strcpy(mask, re_mask(File, FALSE));
|
||||||
if (re_comp(mask))
|
if (re_comp(mask))
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
|
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
|
||||||
|
#else
|
||||||
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
while (fread(&fdb, fdbhdr.recsize, 1, fp) == 1) {
|
||||||
|
#endif
|
||||||
if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
|
if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
|
||||||
Syslog('+', "Will rearc %s", fdb.LName);
|
Syslog('+', "Will rearc %s", fdb.LName);
|
||||||
sprintf(temp, "%s/%s", area.Path, fdb.Name);
|
sprintf(temp, "%s/%s", area.Path, fdb.Name);
|
||||||
@ -185,8 +200,16 @@ void ReArc(int Area, char *File)
|
|||||||
strcpy(temp, mname);
|
strcpy(temp, mname);
|
||||||
}
|
}
|
||||||
free(mname);
|
free(mname);
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||||
|
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
|
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||||
|
mbsedb_UnlockFDB(fdb_area);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fseek(fp, - fdbhdr.recsize, SEEK_CUR);
|
fseek(fp, - fdbhdr.recsize, SEEK_CUR);
|
||||||
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
fwrite(&fdb, fdbhdr.recsize, 1, fp);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update symbolic link to long filename
|
* Update symbolic link to long filename
|
||||||
@ -211,7 +234,11 @@ void ReArc(int Area, char *File)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
mbsedb_CloseFDB(fdb_area);
|
||||||
|
#else
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
#endif
|
||||||
free(temp);
|
free(temp);
|
||||||
Syslog('+', "ReArc Files [%5d] Good [%5d] Errors [%5d]", count, count - errors, errors);
|
Syslog('+', "ReArc Files [%5d] Good [%5d] Errors [%5d]", count, count - errors, errors);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user