-
Notifications
You must be signed in to change notification settings - Fork 2
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
archive crate #8
Changes from 6 commits
3ea6885
0890fd8
b1f4040
ddc92a6
e4c1d79
4dca3b4
0dfd826
51e1232
4fdfa77
09ba2bd
9bd9946
6ca09d9
33d897c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,22 +25,26 @@ impl Fs for LocalFs { | |
} | ||
|
||
async fn ls(&self) -> anyhow::Result<Vec<String>> { | ||
let mut read_dir = tokio::fs::read_dir(self.root.as_path()).await?; | ||
let mut result = Vec::new(); | ||
while let Some(entry) = read_dir.next_entry().await? { | ||
if let Some(name) = entry.file_name().to_str() { | ||
result.push(name.to_string()); | ||
match tokio::fs::read_dir(&self.root).await { | ||
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. Can probably be simplified to If clippy doesn't show it with the default config, you can try running 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. here i can't really use |
||
Ok(mut read_dir) => { | ||
let mut result = Vec::new(); | ||
while let Some(entry) = read_dir.next_entry().await? { | ||
if let Some(name) = entry.file_name().to_str() { | ||
result.push(name.to_string()); | ||
} | ||
} | ||
Ok(result) | ||
} | ||
Err(_) => Ok(vec![]) | ||
} | ||
Ok(result) | ||
} | ||
|
||
async fn move_local(&self, local_src: &Path, dest: &str) -> anyhow::Result<()> { | ||
let dest = self.root.join(dest); | ||
if let Some(dir) = dest.parent() { | ||
tokio::fs::create_dir_all(dir).await?; | ||
} | ||
tokio::fs::rename(local_src, self.root.join(dest)).await?; | ||
tokio::fs::rename(local_src, dest).await?; | ||
Ok(()) | ||
} | ||
|
||
|
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.
Looks like a simple
futures::join(sink.r#loop(), writer.start()).await
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.
futures::join
waits for both futures to complete.JoinSet
supposed to catch an error from the writer task as early as possible.we can easily imagine that smth happened during writing parquets and if we use
join
then the error will be propagated only whensink
is trying to send a new value to already closed channelThere 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.
If they both return
Result
s, this one is even more convenient: https://docs.rs/tokio/latest/tokio/macro.try_join.html