mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 23:18:06 -04:00
fix(volume): restore UUID from database at startup
Volume UUIDs were randomly generated (Uuid::new_v4()) on every startup, causing the frontend to flash/reset on every app launch because React uses volume.id as component keys (DevicePanel.tsx, VolumesGroup.tsx). Fix by including db_vol.uuid in tracked_volumes_map and assigning it to detected.id during the DB metadata merge step in reconcile_volumes(). Volumes recognized by fingerprint now retain their stable database UUID across restarts, while new volumes still get a fresh UUID until tracked. Fixes audit Issue #9 from memory-bank/windows_audit_2026_03.md. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -643,7 +643,7 @@ impl VolumeManager {
|
||||
// Query database for tracked volumes to merge metadata
|
||||
let mut tracked_volumes_map: HashMap<
|
||||
VolumeFingerprint,
|
||||
(Uuid, Option<String>, Option<u64>, Option<u64>),
|
||||
(Uuid, Uuid, Option<String>, Option<u64>, Option<u64>),
|
||||
> = HashMap::new();
|
||||
if let Some(lib_mgr) = library_manager.read().await.as_ref() {
|
||||
if let Some(lib_mgr) = lib_mgr.upgrade() {
|
||||
@@ -673,6 +673,7 @@ impl VolumeManager {
|
||||
fingerprint,
|
||||
(
|
||||
library.id(),
|
||||
db_vol.uuid,
|
||||
db_vol.display_name,
|
||||
db_vol.read_speed_mbps.map(|s| s as u64),
|
||||
db_vol.write_speed_mbps.map(|s| s as u64),
|
||||
@@ -705,9 +706,10 @@ impl VolumeManager {
|
||||
seen_fingerprints.insert(fingerprint.clone());
|
||||
|
||||
// Merge tracked volume metadata from database
|
||||
if let Some((library_id, display_name, read_speed, write_speed)) =
|
||||
if let Some((library_id, db_uuid, display_name, read_speed, write_speed)) =
|
||||
tracked_volumes_map.get(&fingerprint)
|
||||
{
|
||||
detected.id = *db_uuid;
|
||||
detected.is_tracked = true;
|
||||
detected.library_id = Some(*library_id);
|
||||
detected.display_name = display_name.clone();
|
||||
|
||||
Reference in New Issue
Block a user