From 238427331f2e75cf8e15b15090283fd5063b95d2 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Mon, 4 Jun 2018 23:53:28 +0100 Subject: [PATCH] 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 --- cinera/cinera.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cinera/cinera.c b/cinera/cinera.c index 55afd28..6bd49d4 100644 --- a/cinera/cinera.c +++ b/cinera/cinera.c @@ -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);