Skip to content
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

Implement recursive argument for File.delete #9719

Merged
merged 28 commits into from
Apr 17, 2024

Conversation

radeusgd
Copy link
Member

Pull Request Description

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

Comment on lines -119 to -140
group_builder.specify "should not allow to create a directory inside of a regular file" <|
test_file = test_root.get / "test_file.json"
test_file.exists . should_be_true

r = test_file.create_directory "my_test_dir"
r.should_fail_with Illegal_Argument

# TODO expand with #8993
group_builder.specify "should delete all contents of a directory when deleting a directory" <|
dir1 = test_root.get.create_directory "my_test_dir1"+(Random.uuid.take 5)
dir1.should_succeed

dir2 = dir1.create_directory "my_test_dir2"
dir2.should_succeed

dir1.delete . should_succeed

Test.with_retries <|
dir1.exists . should_be_false
# The inner directory should also have been trashed if its parent is removed
dir2.exists . should_be_false

Copy link
Member Author

Choose a reason for hiding this comment

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

These tests were replaced with Local_File_Spec.add_create_and_delete_directory_specs

Copy link
Member Author

Choose a reason for hiding this comment

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

I recommend to look at these changes with 'Hide whitespace changes'

delete : Boolean -> Nothing
delete self (recursive : Boolean = False) =
# TODO improve recursive deletion for S3 folders: https://github.com/enso-org/enso/issues/9704
if self.is_directory then Error.throw (S3_Error.Error "Deleting S3 folders is currently not implemented." self.uri) else
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like S3 folder deletion is implemented in delete_if_exists, why is it different here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I removed that and rephrased the TODO

@radeusgd radeusgd added the CI: Ready to merge This PR is eligible for automatic merge label Apr 17, 2024
@mergify mergify bot merged commit 34f3331 into develop Apr 17, 2024
36 of 37 checks passed
@mergify mergify bot deleted the wip/radeusgd/8993-file-delete-recursive branch April 17, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

recursive option for File.delete
4 participants