Fix Critical: IndexSystem lock races and TrackRepository.Update silent-create

- Replace object lock with SemaphoreSlim(1,1) on both DirectoryIndexDirectory
  and VaultIndexDirectory; SaveIndexAsync now executes inside the semaphore
  so mutate+persist is atomic
- ReloadIndexAsync acquires the semaphore before LoadIndexAsync so disk load
  and in-memory swap are atomic with respect to concurrent writes
- HasIndexEntry and GetEntryMetadata converted to async Task with WaitAsync;
  MediaVault.GetEntryAsync call sites updated accordingly
- TrackRepository.Update throws InvalidOperationException when Id not found
  instead of silently calling Create; service layer catches and wraps as fail result
This commit is contained in:
Daniel Harvey
2026-05-17 11:24:50 -04:00
parent 56d15027e4
commit 4a0c17c318
6 changed files with 57 additions and 31 deletions
@@ -50,7 +50,7 @@ public class TrackRepository
if (trackEntity == null)
{
return await Create(track);
throw new InvalidOperationException($"Track not found: {track.Id}");
}
trackEntity.Album = track.Album;