A bucket file that parsed as a JSON array or other non-object was treated
as empty and then overwritten on the next save, so the previous contents
were gone. Those files are now moved aside like invalid JSON. A backup
created in the same second no longer replaces an existing one.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: AE <by-ae@users.noreply.github.com>
The per-bucket lock was inserted without synchronization. Two first
writers could take different locks and overwrite each other's preset
file. Lock creation now happens under a guard lock.
Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
test_store replaced the folder_paths mock after store.py had imported it.
Route tests then configured the replacement, and store writes went to a
MagicMock path that had been committed. Both suites now share the mock
from conftest and land files in a temp directory.
Co-authored-by: AE <by-ae@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Allow Unicode letters/numbers in preset names (e.g. 角色, Персонаж, Émilie)
- Add thread-safe locking per bucket to prevent race conditions during concurrent writes
- Use mkstemp() for atomic temp file creation to avoid tmp file name collisions
- Add tests demonstrating the bugs and verifying the fixes
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Test corrupt JSON creates backup and returns empty bucket
- Test corrupt file does not affect other buckets
- Test save works after corrupt file recovery
- Test DELETE success, 404 not found, invalid bucket/name 400
- All existing tests continue to pass
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Implement 10 unit tests covering:
- Name validation (valid and invalid patterns)
- Save, load, and delete operations
- Multiple entries and overwrites
- Empty buckets and non-existent entries
- Invalid bucket names
- Persistence across reloads
Tests use unittest (stdlib) and mock folder_paths dependency,
ensuring the store logic is reliable without ComfyUI runtime.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>