fix(volume): preserve DB UUID on cache refresh

When a tracked volume gets updated in the cache (mount status change,
space change, etc.), line 741 was overwriting the ID with existing.id
which could be an ephemeral Uuid::new_v4() if the cache was populated
before DB metadata was merged (startup race condition). This defeats
the stable UUID fix from 4f387eede.

Now prefers the DB UUID from tracked_volumes_map when available,
falling back to existing.id only for untracked volumes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
slvnlrt
2026-03-15 19:20:56 +01:00
parent 1ff018454c
commit e6b9a630df

View File

@@ -736,9 +736,12 @@ impl VolumeManager {
|| old_info.total_bytes_available != new_info.total_bytes_available
|| old_info.error_status != new_info.error_status
{
// Update the volume - preserve existing ID for cache stability
// Update the volume - prefer DB UUID for stability, fall back to cache ID
let mut updated_volume = detected.clone();
updated_volume.id = existing.id;
updated_volume.id = tracked_volumes_map
.get(&fingerprint)
.map(|(_, db_uuid, ..)| *db_uuid)
.unwrap_or(existing.id);
updated_volume.update_info(new_info.clone());
current_volumes.insert(fingerprint.clone(), updated_volume.clone());