Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented Apr 29, 2025

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
Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

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!

@@ -95,9 +95,14 @@ impl FileIO {
/// # Arguments
///
/// * 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
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
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

@@ -95,9 +95,14 @@ impl FileIO {
/// # Arguments
///
/// * 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
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
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.

@@ -95,9 +95,14 @@ impl FileIO {
/// # Arguments
///
/// * 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
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
Copy link
Member Author

Xuanwo commented May 6, 2025

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
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