NikitaMatskevich commented on code in PR #7182: URL: https://github.com/apache/opendal/pull/7182#discussion_r2782636785
########## core/src/docs/rfcs/0000_undelete.md: ########## @@ -0,0 +1,648 @@ +- Proposal Name: (`undelete`) +- Start Date: 2025-02-04 +- RFC PR: [apache/opendal#7178](https://github.com/apache/opendal/pull/7178) +- Tracking Issue: [apache/opendal#4321](https://github.com/apache/opendal/issues/4321) + +# Summary + +Implement two complementary approaches for restoring deleted files in OpenDAL: + +1. **Version-based restoration**: Extend the `copy` operation with an optional source `version` parameter to enable promoting non-current versions to the current version (for storage systems with versioning support) +2. **Soft delete restoration**: Add an `undelete` operation for storage systems that implement soft delete as a distinct feature from versioning (GCS and Azure Blob Storage) +3. Provide a high-level `restore` API that automatically chooses the right approach based on service capabilities, defaulting to versioning approach: + +```rust +impl Operator { + pub async fn restore(&self, path: &str, version: Option<&str>) -> Result<()> { + let cap = self.info().full_capability(); + + if let Some(v) = version { + // Restore specific version via copy + if cap.versioning { + return self.copy_with(&path, &path).source_version(&v).await; + } + } else { + // Restore soft-deleted via undelete + if cap.undelete { + return self.undelete(path).await; + } + + // Fall back to latest version via copy + if cap.versioning && cap.list_with_versions { + let version = self.get_latest_version(path).await?; + return self.copy_with(&path, &path).source_version(&version).await; + } Review Comment: It might be possible to abstract this logic and put it at the interface level. Its similar for many backends, that's why I kept it here. Implementing this separately in every backend would be equivalent to have restore == undelete, as one can implement undelete through versioning or soft-delete based on available capabilities. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
