Skip to content

refactor: Add FileIO::remove_dir_all to deprecate remove_dir - #1275

Merged
liurenjie1024 merged 3 commits into
mainfrom
fix-remove-all
May 15, 2025
Merged

liurenjie1024 merged 3 commits into
mainfrom
fix-remove-all

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Apr 29, 2025

Copy link
Copy Markdown
Member

Which issue does this PR close?

What changes are included in this PR?

Change FileIO::remove_all to remove_dir_all to make it's behavior more clear.

Are these changes tested?

@Xuanwo
Xuanwo requested a review from liurenjie1024 April 29, 2025 16:56

@liurenjie1024 liurenjie1024 left a comment

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.

Thanks @Xuanwo for this pr, just a nit!

///
/// * path: It should be *absolute* path starting with scheme string used to construct [`FileIO`].
pub async fn remove_all(&self, path: impl AsRef<str>) -> Result<()> {
pub async fn remove_dir_all(&self, path: impl AsRef<str>) -> Result<()> {

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.

  1. It would be better to add doc to explain the behavior, e.g. what if the dir doesn't exist, what if the dir is empty.
  2. Add test case for path not ending with "/"

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.

maybe also add a test for if the path (without ending in /) refers to a file instead of dir. should be no-op

///
/// * path: It should be *absolute* path starting with scheme string used to construct [`FileIO`].
pub async fn remove_all(&self, path: impl AsRef<str>) -> Result<()> {
pub async fn remove_dir_all(&self, path: impl AsRef<str>) -> Result<()> {

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.

is this a breaking change? i.e. something we should warn users about on the next release

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.

+1, we could deprecate the old one, and recommend the new api.

Comment thread crates/iceberg/src/io/file_io.rs Resolved
///
/// * path: It should be *absolute* path starting with scheme string used to construct [`FileIO`].
pub async fn remove_all(&self, path: impl AsRef<str>) -> Result<()> {
pub async fn remove_dir_all(&self, path: impl AsRef<str>) -> Result<()> {

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.

maybe also add a test for if the path (without ending in /) refers to a file instead of dir. should be no-op

@Xuanwo

Xuanwo commented May 6, 2025

Copy link
Copy Markdown
Member Author

Thank you all for the review, I will start addressing them today.

@Xuanwo Xuanwo changed the title refactor!: Change FileIO::remove_all to remove_dir_all refactor: Add FileIO::remove_dir_all to deprecate remove_dir May 14, 2025

@kevinjqliu kevinjqliu left a comment

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.

LGTM!

cc @liurenjie1024 to take a final look.
cc @c-thiel as well since he opened the original issue

@liurenjie1024 liurenjie1024 left a comment

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.

Thanks @Xuanwo for this pr!

@liurenjie1024
liurenjie1024 merged commit 141b997 into main May 15, 2025
@liurenjie1024
liurenjie1024 deleted the fix-remove-all branch May 15, 2025 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected FileIO remove_all behavior for S3

3 participants