From d283297bc691935ffce5133c2020c4bcf873fa19 Mon Sep 17 00:00:00 2001 From: Jamie Pine Date: Fri, 25 Jul 2025 06:09:19 -0400 Subject: [PATCH] refactor(core): Remove unused library_id field from SdPath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The library_id field in SdPath was not being used in any file operations and didn't make sense as part of the core path abstraction. Library context is better handled at higher levels (events, services) rather than being embedded in every path reference. Changes: - Remove library_id field from SdPath struct - Remove with_library() constructor method - Update all constructors and methods to not reference library_id - Update SdPathSerialized to match - Update all documentation examples and references This simplifies SdPath to focus purely on cross-device file path representation with just device_id and path fields. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- core-new/README.md | 1 - .../CROSS_PLATFORM_COPY_AND_VOLUME_AWARENESS.md | 6 ------ core-new/docs/design/DESIGN_FILE_DATA_MODEL.md | 7 +++---- core-new/docs/design/DOMAIN_MODELS_README.md | 2 +- core-new/src/domain/entry.rs | 5 ----- core-new/src/shared/types.rs | 17 ----------------- 6 files changed, 4 insertions(+), 34 deletions(-) diff --git a/core-new/README.md b/core-new/README.md index 239b0e2c8..ebc192621 100644 --- a/core-new/README.md +++ b/core-new/README.md @@ -70,7 +70,6 @@ The foundation for virtual distributed file systems: pub struct SdPath { device_id: Uuid, // Which device path: PathBuf, // Path on that device - library_id: Option, // Optional library context } impl SdPath { diff --git a/core-new/docs/design/CROSS_PLATFORM_COPY_AND_VOLUME_AWARENESS.md b/core-new/docs/design/CROSS_PLATFORM_COPY_AND_VOLUME_AWARENESS.md index 108e05c56..54d404257 100644 --- a/core-new/docs/design/CROSS_PLATFORM_COPY_AND_VOLUME_AWARENESS.md +++ b/core-new/docs/design/CROSS_PLATFORM_COPY_AND_VOLUME_AWARENESS.md @@ -231,7 +231,6 @@ pub enum CopyResult { pub struct SdPath { pub device_id: Uuid, // ❌ Stored - should be computed pub path: PathBuf, - pub library_id: Option, } ``` @@ -243,9 +242,6 @@ pub struct SdPath { pub struct SdPath { /// The local path - this is the only stored data pub path: PathBuf, - - /// Optional library context - pub library_id: Option, } /// Extended path information - computed at runtime @@ -263,7 +259,6 @@ pub struct SdPathInfo { #[derive(Serialize, Deserialize)] pub struct SdPathSerialized { pub path: PathBuf, - pub library_id: Option, // Note: device_id and volume info NOT serialized } @@ -314,7 +309,6 @@ impl SdPath { pub struct SdPathRemote { pub device_id: Uuid, // Required for remote paths pub path: PathBuf, - pub library_id: Option, pub last_known_volume: Option, } ``` diff --git a/core-new/docs/design/DESIGN_FILE_DATA_MODEL.md b/core-new/docs/design/DESIGN_FILE_DATA_MODEL.md index 18b097dd6..93aadffa2 100644 --- a/core-new/docs/design/DESIGN_FILE_DATA_MODEL.md +++ b/core-new/docs/design/DESIGN_FILE_DATA_MODEL.md @@ -120,13 +120,12 @@ How SdPath is stored in the database: struct SdPathSerialized { device_id: Uuid, path: String, // Normalized path - library_id: Option, } // In the database, this could be: -// - Three columns: device_id, path, library_id -// - Or JSON: {"device_id": "...", "path": "...", "library_id": null} -// - Or a custom format: "device_id://path" or "library_id/device_id://path" +// - Two columns: device_id, path +// - Or JSON: {"device_id": "...", "path": "..."} +// - Or a custom format: "device_id://path" ``` ### 5. Location (Enhanced) diff --git a/core-new/docs/design/DOMAIN_MODELS_README.md b/core-new/docs/design/DOMAIN_MODELS_README.md index cd4621b86..4da4f829d 100644 --- a/core-new/docs/design/DOMAIN_MODELS_README.md +++ b/core-new/docs/design/DOMAIN_MODELS_README.md @@ -10,7 +10,7 @@ The foundation of the VDFS. Represents any file or directory that Spacedrive kno ```rust let entry = Entry { id: Uuid::new_v4(), - sd_path: SdPathSerialized { device_id, path, library_id }, + sd_path: SdPathSerialized { device_id, path }, name: "vacation.jpg", kind: EntryKind::File { extension: Some("jpg") }, metadata_id: metadata.id, // ALWAYS has metadata! diff --git a/core-new/src/domain/entry.rs b/core-new/src/domain/entry.rs index a96bef34c..e6cd79fd7 100644 --- a/core-new/src/domain/entry.rs +++ b/core-new/src/domain/entry.rs @@ -79,9 +79,6 @@ pub struct SdPathSerialized { /// Normalized path on that device pub path: String, - - /// Optional library context - pub library_id: Option, } impl SdPathSerialized { @@ -90,7 +87,6 @@ impl SdPathSerialized { Self { device_id: sdpath.device_id, path: sdpath.path.to_string_lossy().to_string(), - library_id: sdpath.library_id, } } @@ -99,7 +95,6 @@ impl SdPathSerialized { SdPath { device_id: self.device_id, path: self.path.clone().into(), - library_id: self.library_id, } } } diff --git a/core-new/src/shared/types.rs b/core-new/src/shared/types.rs index e23a7e589..c9cca2452 100644 --- a/core-new/src/shared/types.rs +++ b/core-new/src/shared/types.rs @@ -20,10 +20,6 @@ pub struct SdPath { /// The local path on that device pub path: PathBuf, - - /// Optional library context - /// If None, uses the current active library - pub library_id: Option, } impl SdPath { @@ -32,25 +28,15 @@ impl SdPath { Self { device_id, path: path.into(), - library_id: None, } } - /// Create an SdPath with a specific library - pub fn with_library(device_id: Uuid, path: impl Into, library_id: Uuid) -> Self { - Self { - device_id, - path: path.into(), - library_id: Some(library_id), - } - } /// Create an SdPath for a local file on this device pub fn local(path: impl Into) -> Self { Self { device_id: get_current_device_id(), // Get the current device ID path: path.into(), - library_id: None, } } @@ -87,7 +73,6 @@ impl SdPath { self.path.parent().map(|p| SdPath { device_id: self.device_id, path: p.to_path_buf(), - library_id: self.library_id, }) } @@ -96,7 +81,6 @@ impl SdPath { SdPath { device_id: self.device_id, path: self.path.join(path), - library_id: self.library_id, } } @@ -191,7 +175,6 @@ mod tests { assert_eq!(path.device_id, device_id); assert_eq!(path.path, PathBuf::from("/home/user/file.txt")); - assert_eq!(path.library_id, None); } #[test]