cinera.c: Generate index if any files changed

Previously it could fail to generate an index if the processing of the
final file set "Inserted" or "Deleted" to FALSE, even if a prior file
had set it to TRUE
This commit is contained in:
Matt Mascarenhas 2018-06-04 23:53:28 +01:00
parent fc7c28c047
commit 238427331f
1 changed files with 5 additions and 8 deletions

View File

@ -16,7 +16,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 5,
.Patch = 54
.Patch = 55
};
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
@ -5841,11 +5841,11 @@ MonitorDirectory(index *Index, buffers *CollationBuffers, template *IndexTemplat
// TODO(matt): Maybe handle IN_ALL_EVENTS
if(FinalFileEvents[FinalFileEventsIndex]->mask & IN_DELETE || FinalFileEvents[FinalFileEventsIndex]->mask & IN_MOVED_FROM)
{
Deleted = (DeleteEntry(Index, &Neighbourhood, FinalFileEvents[FinalFileEventsIndex]->name) == RC_SUCCESS);
Deleted |= (DeleteEntry(Index, &Neighbourhood, FinalFileEvents[FinalFileEventsIndex]->name) == RC_SUCCESS);
}
else
{
Inserted = (InsertEntry(Index, &Neighbourhood, CollationBuffers, PlayerTemplate, BespokeTemplate, FinalFileEvents[FinalFileEventsIndex]->name, 0) == RC_SUCCESS);
Inserted |= (InsertEntry(Index, &Neighbourhood, CollationBuffers, PlayerTemplate, BespokeTemplate, FinalFileEvents[FinalFileEventsIndex]->name, 0) == RC_SUCCESS);
}
}
@ -6206,10 +6206,7 @@ int
SyncIndexWithInput(index *Index, buffers *CollationBuffers, template *IndexTemplate, template *PlayerTemplate, template *BespokeTemplate)
{
bool Deleted = FALSE;
if(Index->Metadata.FileSize > 0 && Index->File.FileSize > 0 && DeleteDeadIndexEntries(Index) == RC_SUCCESS)
{
Deleted = TRUE;
}
Deleted = (Index->Metadata.FileSize > 0 && Index->File.FileSize > 0 && DeleteDeadIndexEntries(Index) == RC_SUCCESS);
DIR *ProjectDirHandle;
if(!(ProjectDirHandle = opendir(Config.ProjectDir)))
@ -6232,7 +6229,7 @@ SyncIndexWithInput(index *Index, buffers *CollationBuffers, template *IndexTempl
neighbourhood Neighbourhood = { };
Neighbourhood.PrevIndex = -1;
Neighbourhood.NextIndex = -1;
Inserted = (InsertEntry(Index, &Neighbourhood, CollationBuffers, PlayerTemplate, BespokeTemplate, ProjectFiles->d_name, 0) == RC_SUCCESS);
Inserted |= (InsertEntry(Index, &Neighbourhood, CollationBuffers, PlayerTemplate, BespokeTemplate, ProjectFiles->d_name, 0) == RC_SUCCESS);
}
}
closedir(ProjectDirHandle);