From e6b9a630df2281812b50a162c56ffa8b6ddbccbb Mon Sep 17 00:00:00 2001 From: slvnlrt Date: Sun, 15 Mar 2026 19:20:56 +0100 Subject: [PATCH] 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 --- core/src/volume/manager.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/volume/manager.rs b/core/src/volume/manager.rs index 98dcb78fa..ffe13caa3 100644 --- a/core/src/volume/manager.rs +++ b/core/src/volume/manager.rs @@ -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());