diff --git a/src/Chronos.Data/Projects/ProjectIndexer.cs b/src/Chronos.Data/Projects/ProjectIndexer.cs index a32ce0a9..7f0b4277 100644 --- a/src/Chronos.Data/Projects/ProjectIndexer.cs +++ b/src/Chronos.Data/Projects/ProjectIndexer.cs @@ -24,7 +24,8 @@ internal sealed record ProjectReconcile(bool Missing, IReadOnlySet Seen, I /// behind on moves forward, a name or deletion recorded since is taken, and a row the index marked deleted is listed again /// when its live record says it is not. Only a record that says so, live or in the projects' trash, deletes a project: /// never a folder that is not there (moved for a moment, a backup put back, a sync tool) nor a record that cannot be read, -/// whose project stays as the index has it (). A version file written past its +/// whose project stays as the index has it (); a record missing from the folder of a +/// live project the index holds is written again from the index when the archive takes writes. A version file written past its /// record's head by a push a crash cut short is adopted when it follows the head (its file is complete: versions are /// written atomically, then the record); any other file past the head, or a second file of a number the record's chain /// names another for, is moved aside to versions/.stray, never deleted. Runs under the sequence's lease, or without @@ -34,6 +35,9 @@ internal sealed class ProjectIndexer(ChronosDatabase db) { private const string StrayFolder = ".stray"; + /// Versions read at once when a project's sidecars are written again from the index. + private const int WriteBackPage = 500; + /// Reconciles the projects of in ; the caller holds the sequence's lease. /// False for a read-only archive: the sidecars are read as they are and only the index is written /// (a version past its record's head is indexed, not adopted into the record; nothing is moved aside). @@ -46,29 +50,39 @@ internal sealed class ProjectIndexer(ChronosDatabase db) foreach (var (directory, trashed) in ProjectFolders(folder)) { cancellationToken.ThrowIfCancellationRequested(); - ProjectRecord record; + ProjectRecord? record = null; + var recordPath = Path.Combine(directory, ArchiveLayout.ProjectFile); try { - record = ProjectSidecars.ReadRecord(Path.Combine(directory, ArchiveLayout.ProjectFile)); + record = ProjectSidecars.ReadRecord(recordPath); } catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException) { // Its folder names it (, or -