.tasks/core/FSYNC-001-delete-strategy-pattern.md
Bring DeleteJob up to parity with FileCopyJob's architecture by implementing the strategy pattern with local and remote delete capabilities. This enables File Sync to dispatch delete operations across devices.
Current State: DeleteJob only supports local deletion with no routing logic Target State: DeleteJob uses strategy pattern with local and remote strategies
File Sync needs to delete files on remote devices as part of Mirror and Bidirectional sync modes. The current DeleteJob lacks:
// Location: core/src/ops/files/delete/strategy.rs
#[async_trait]
pub trait DeleteStrategy: Send + Sync {
async fn execute(
&self,
ctx: &JobContext<'_>,
paths: &[SdPath],
mode: DeleteMode,
) -> Result<Vec<DeleteResult>>;
}
pub struct DeleteResult {
pub path: SdPath,
pub success: bool,
pub bytes_freed: u64,
pub error: Option<String>,
}
Move existing DeleteJob logic into LocalDeleteStrategy:
move_to_trash() for DeleteMode::Trashpermanent_delete() for DeleteMode::Permanentsecure_delete() for DeleteMode::Secure// core/src/ops/files/delete/strategy.rs
pub struct RemoteDeleteStrategy;
impl DeleteStrategy for RemoteDeleteStrategy {
async fn execute(&self, ctx, paths, mode) -> Result<Vec<DeleteResult>> {
// Group paths by target device
// Send delete request to each device via networking service
// Parse response and return aggregated results
}
}
Network Protocol:
pub enum FileDeleteMessage {
Request {
paths: Vec<SdPath>,
mode: DeleteMode,
request_id: Uuid,
},
Response {
request_id: Uuid,
results: Vec<DeleteResult>,
},
}
// core/src/ops/files/delete/routing.rs
pub struct DeleteStrategyRouter;
impl DeleteStrategyRouter {
pub async fn select_strategy(
paths: &[SdPath],
volume_manager: Option<&VolumeManager>,
) -> Box<dyn DeleteStrategy> {
let all_local = paths.iter().all(|p| p.is_local());
if all_local {
Box::new(LocalDeleteStrategy)
} else {
Box::new(RemoteDeleteStrategy)
}
}
}
Refactor DeleteJob::run() to:
New Files:
core/src/ops/files/delete/strategy.rs - Strategy trait and implementationscore/src/ops/files/delete/routing.rs - Strategy routerModified Files:
core/src/ops/files/delete/job.rs - Refactor to use strategiescore/src/ops/files/delete/mod.rs - Export new modulesNetworking:
core/src/service/networking/handlers.rs - Add file_delete handler2025-10-15: COMPLETE
strategy.rs with DeleteStrategy trait, LocalDeleteStrategy, RemoteDeleteStrategy (~350 lines)routing.rs with DeleteStrategyRouter (~50 lines)file_delete.rs network protocol handler (~250 lines)delete_strategy_test.rs (7 tests)2025-10-15: VolumeBackend Integration
delete() method to VolumeBackend trait (core/src/volume/backend/mod.rs)delete_cloud_path() helper for cloud deletion routingWhy Strategy Pattern?
Networking Integration: Reuses existing P2P infrastructure: