RFC-7182: file restoration API#7182
Conversation
| 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; | ||
| } |
There was a problem hiding this comment.
Would it make sense to let backends handle this themselves ?
There was a problem hiding this 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.
a6eaaa7 to
6403cc3
Compare
There was a problem hiding this comment.
I wanted this API for a long time, but I couldn't figure out the correct API. Thank you for working on this!
After revewing the PR and giving it more thinking, I think we shouldn't provide restore as just a wrapper, and mixed it up with copy / delete / undelete.
Instead, we just expose a restore operation and services just need to implement restore based on the API they have.
From the user's view, they will use the API like:
// I deleted it, make it live again.
op.restore("foo").await?;
// I want to roll back to this version.
op.restore_with("foo").version(v).await?;
// I want to roll back only if nobody recreated it.
op.restore_with("foo").version(v).if_not_exists(true).await?;From the services' view, they will implement the restore API with their own API.
S3:
- restore("foo"): list deleted path -> delete the marker
- restore_with("foo").version(v): copy the version
Gcs:
- restore("foo"): list deleted path -> copy the version
- restore_with("foo").version(v): copy the version
Azblob:
- restore("foo"): undelete
- restore_with("foo").version(v): copy the version
I think in this way, we have the best API for users.
Note: users can still access the power via delete the marker or copy the source version, but they are not part of this RFC.
Which issue does this PR close?
Closes ##7178.
Rationale for this change
Explained in the RFC.
What changes are included in this PR?
An RFC doc stating the future feature design choices, to be reviewed and agreed upon.