mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-23 15:59:42 -04:00
refactor(core): Remove unused library_id field from SdPath
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<Uuid>, // Optional library context
|
||||
}
|
||||
|
||||
impl SdPath {
|
||||
|
||||
@@ -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<Uuid>,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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<Uuid>,
|
||||
}
|
||||
|
||||
/// 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<Uuid>,
|
||||
// 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<Uuid>,
|
||||
pub last_known_volume: Option<VolumeFingerprint>,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -120,13 +120,12 @@ How SdPath is stored in the database:
|
||||
struct SdPathSerialized {
|
||||
device_id: Uuid,
|
||||
path: String, // Normalized path
|
||||
library_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -79,9 +79,6 @@ pub struct SdPathSerialized {
|
||||
|
||||
/// Normalized path on that device
|
||||
pub path: String,
|
||||
|
||||
/// Optional library context
|
||||
pub library_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Uuid>,
|
||||
}
|
||||
|
||||
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<PathBuf>, 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<PathBuf>) -> 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]
|
||||
|
||||
Reference in New Issue
Block a user