cinera.c: Fix index reinsertion bug
This commit is contained in:
parent
acbe38b01f
commit
6b1156292c
|
@ -14,7 +14,7 @@ typedef struct
|
|||
version CINERA_APP_VERSION = {
|
||||
.Major = 0,
|
||||
.Minor = 5,
|
||||
.Patch = 21
|
||||
.Patch = 22
|
||||
};
|
||||
|
||||
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
|
||||
|
@ -2521,6 +2521,10 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen
|
|||
if(MarkerIndex < Anno->marker_count &&
|
||||
InPtr - Anno->text == Anno->markers[MarkerIndex].offset)
|
||||
{
|
||||
// TODO(matt): Consider switching on the Anno->markers[MarkerIndex].type and 100% ensuring this is all correct
|
||||
// I wonder if HMML_CATEGORY should do InPtr += StringLength(Readable); like the others, and also whether HMML_MEMBER and HMML_PROJECT could be
|
||||
// identical, except only for their class ("member" and "project" respectively)
|
||||
// Pretty goddamn sure we can totally compress these cases, but let's do it tomorrow when we're fresh
|
||||
char *Readable = Anno->markers[MarkerIndex].parameter
|
||||
? Anno->markers[MarkerIndex].parameter
|
||||
: Anno->markers[MarkerIndex].marker;
|
||||
|
@ -3833,6 +3837,14 @@ SeekBufferForString(buffer *Buffer, char *String,
|
|||
// TODO(matt): Increment CINERA_DB_VERSION!
|
||||
typedef struct
|
||||
{
|
||||
// NOTE(matt): Consider augmenting this to contain such stuff as: "hex signature"
|
||||
// InitialDBVersion
|
||||
// CurrentDBVersion
|
||||
// InitialAppVersion
|
||||
// CurrentAppVersion
|
||||
// InitialHMMLVersion
|
||||
// CurrentHMMLVersion
|
||||
|
||||
unsigned int DBVersion; // NOTE(matt): Put this first to aid reliability
|
||||
version AppVersion;
|
||||
version HMMLVersion;
|
||||
|
@ -3887,8 +3899,34 @@ InsertIntoIndex(buffers *CollationBuffers, template **BespokeTemplate, char *Bas
|
|||
break;
|
||||
}
|
||||
|
||||
// TODO(matt): Remove this little scope after 0.5.22 has been run once and all the searches are working correctly
|
||||
if(IndexMetadataFileReadCode == RC_SUCCESS)
|
||||
{
|
||||
Index.Header = *(index_header *)Index.Metadata.Buffer.Ptr;
|
||||
|
||||
if(Index.Header.AppVersion.Major < 0 ||
|
||||
Index.Header.AppVersion.Minor < 5 ||
|
||||
Index.Header.AppVersion.Patch < 22)
|
||||
{
|
||||
CopyString(Index.File.Path, "%s/%s.index", Config.BaseDir, Config.ProjectID);
|
||||
fprintf(stderr, "\e[1;31mRemoving %s and %s generated by Cinera version %d.%d.%d\n"
|
||||
"prior to the index reinsertion fix implemented in version 0.5.22\e[0m\n",
|
||||
Index.Metadata.Path, Index.File.Path,
|
||||
Index.Header.AppVersion.Major,
|
||||
Index.Header.AppVersion.Minor,
|
||||
Index.Header.AppVersion.Patch);
|
||||
|
||||
FreeBuffer(&Index.Metadata.Buffer);
|
||||
IndexMetadataFileReadCode = RC_ERROR_FILE;
|
||||
remove(Index.Metadata.Path);
|
||||
remove(Index.File.Path);
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
Index.File.Buffer.ID = "IndexFile";
|
||||
CopyString(Index.File.Path, "%s/%s.index", Config.BaseDir, Config.ProjectID);
|
||||
|
||||
int IndexFileReadCode = ReadFileIntoBuffer(&Index.File, 0);
|
||||
switch(IndexFileReadCode)
|
||||
{
|
||||
|
@ -3950,7 +3988,7 @@ InsertIntoIndex(buffers *CollationBuffers, template **BespokeTemplate, char *Bas
|
|||
// Reinsert
|
||||
MetadataInsertionOffset = Index.Metadata.Buffer.Ptr - Index.Metadata.Buffer.Location;
|
||||
IndexEntryInsertionStart = IndexEntryStart - Index.File.Buffer.Location;
|
||||
IndexEntryInsertionEnd = IndexEntryInsertionStart + Index.Entry.Size;
|
||||
IndexEntryInsertionEnd = IndexEntryInsertionStart + This.Size;
|
||||
Found = TRUE;
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue