This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Fallback to synchronous rm_dir call if path moving fails #27306
Merged
xiangzhu70
merged 1 commit into
solana-labs:master
from
xiangzhu70:account_files_remove_fallback
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2056,28 +2056,26 @@ fn move_and_async_delete_path(path: impl AsRef<Path> + Copy) { | |
| )); | ||
|
|
||
| if path_delete.exists() { | ||
| debug!("{} exists, delete it first.", path_delete.display()); | ||
| std::fs::remove_dir_all(&path_delete).unwrap(); | ||
| } | ||
|
|
||
| if !path.as_ref().exists() { | ||
| info!( | ||
| "move_and_async_delete_path: path {} does not exist", | ||
| path.as_ref().display() | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| std::fs::rename(&path, &path_delete).unwrap(); | ||
| if let Err(err) = std::fs::rename(&path, &path_delete) { | ||
| warn!( | ||
| "Path renaming failed: {}. Falling back to rm_dir in sync mode", | ||
| err.to_string() | ||
| ); | ||
| std::fs::remove_dir_all(&path).unwrap(); | ||
| return; | ||
| } | ||
|
|
||
| Builder::new() | ||
| .name("solDeletePath".to_string()) | ||
| .spawn(move || { | ||
| std::fs::remove_dir_all(&path_delete).unwrap(); | ||
| info!( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did find this log mesage useful fwiw |
||
| "Cleaning path {} done asynchronously in a spawned thread", | ||
| path_delete.display() | ||
| ); | ||
| }) | ||
| .unwrap(); | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like we can easily avoid this early return by using an
} else {There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually let the the function do the early return for various exceptions, and let the later main part of the function represent the more likely flow, and avoid too much indention in that part. I can make the change if less early return is really preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My pref in this case would be to remove the early return but I'm not going to attempt to force compliance.