File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,14 @@ pub struct BufferedStringWriter {
1515
1616impl BufferedStringWriter {
1717 pub async fn from_file ( filename : & Path ) -> Result < Self , std:: io:: Error > {
18- let metadata = tokio:: fs:: metadata ( filename) . await ?;
19- let writer = if metadata. is_dir ( ) {
18+ let exists = tokio:: fs:: try_exists ( filename) . await ?;
19+ let is_dir = if exists {
20+ let metadata = tokio:: fs:: metadata ( filename) . await ?;
21+ metadata. is_dir ( )
22+ } else {
23+ false
24+ } ;
25+ let writer = if exists && is_dir {
2026 let mut dir_contents = tokio:: fs:: read_dir ( filename) . await ?;
2127 if dir_contents. next_entry ( ) . await ?. is_some ( ) {
2228 return Err ( std:: io:: Error :: new (
@@ -49,6 +55,7 @@ impl BufferedStringWriter {
4955 Ok ( ( ) )
5056 }
5157
58+ #[ allow( clippy:: get_first) ]
5259 pub async fn flush ( & mut self , only_contiguous : bool ) -> Result < ( ) , std:: io:: Error > {
5360 // Sort by the 5 character key at the beginning of the file
5461 // This matches the first 5 characters of the first row
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ pub struct MyStruct {
1313 pub hash : String ,
1414}
1515
16+ #[ allow( clippy:: non_canonical_partial_ord_impl) ]
1617impl PartialOrd for MyStruct {
1718 fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
1819 // reverse order (highest to lowest)
You can’t perform that action at this time.
0 commit comments