Files
duplicati/Duplicati/Library/Utility
JamBalaya56562andClaude Opus 4.8 e772a800d4 Fix flaky temp-file name collision in debug builds
TempFile.GenerateUniqueName (DEBUG only) builds each name from the caller, a
second-precision timestamp, and the first 8 characters of a Guid, then adds it
to a static tracking dictionary. When many temp files are created within the
same second by the same caller (e.g. BorderTests.Run10kTzstdCompressionAsync,
which writes ~10k blocks), the 8-char Guid prefix can collide, so the generated
name repeats: Dictionary.Add throws "An item with the same key has already been
added", and two TempFiles would otherwise share the same path. Release builds
are unaffected (full Guid, no dictionary).

Append a process-wide atomic counter to the generated name so it is always
unique regardless of timestamp granularity or Guid-prefix collisions. Expose
GenerateUniqueName as internal (Library.Utility already grants InternalsVisibleTo
to the unit-test project) and add a concurrency stress test asserting the
generated names never throw and are all unique.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 07:31:05 +09:00
..
2026-06-27 11:43:28 +02:00
2026-06-27 11:43:28 +02:00