Skip to content

RFC-7182: file restoration API#7182

Open
NikitaMatskevich wants to merge 2 commits into
apache:mainfrom
NikitaMatskevich:nmh/add-undelete-rfc
Open

RFC-7182: file restoration API#7182
NikitaMatskevich wants to merge 2 commits into
apache:mainfrom
NikitaMatskevich:nmh/add-undelete-rfc

Conversation

@NikitaMatskevich
Copy link
Copy Markdown

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.

@NikitaMatskevich NikitaMatskevich marked this pull request as ready for review February 7, 2026 09:16
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. releases-note/docs The PR modifies docs related content or has a title that begins with "docs" labels Feb 7, 2026
Comment on lines +19 to +34
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;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to let backends handle this themselves ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread core/src/docs/rfcs/0000_undelete.md Outdated
Comment thread core/core/src/docs/rfcs/7182_restore_api.md
@meteorgan meteorgan changed the title docs: add an RFC for file restoration API RFC-7182: file restoration API Feb 7, 2026
Copy link
Copy Markdown
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NikitaMatskevich

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/docs The PR modifies docs related content or has a title that begins with "docs" size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants