Browse Source
Apply `duration_suboptimal_units` lint findings (#7144 )
Quote from lint description:
"Using a smaller unit for a duration that is evenly divisible by a larger unit reduces readability. Readers have to mentally convert values, which can be error-prone and makes the code less clear."
pull/7157/head
Daniel
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
5 additions and
4 deletions
Cargo.toml
src/api/core/sends.rs
src/api/core/two_factor/webauthn.rs
src/db/models/attachment.rs
src/util.rs
@ -301,6 +301,7 @@ branches_sharing_code = "deny"
case_sensitive_file_extension_comparisons = "deny"
case_sensitive_file_extension_comparisons = "deny"
cast_lossless = "deny"
cast_lossless = "deny"
clone_on_ref_ptr = "deny"
clone_on_ref_ptr = "deny"
duration_suboptimal_units = "deny"
equatable_if_let = "deny"
equatable_if_let = "deny"
excessive_precision = "deny"
excessive_precision = "deny"
filter_map_next = "deny"
filter_map_next = "deny"
@ -574,7 +574,7 @@ async fn download_url(host: &Host, send_id: &SendId, file_id: &SendFileId) -> Re
Ok ( format ! ( "{}/api/sends/{send_id}/{file_id}?t={token}" , & host . host ) )
Ok ( format ! ( "{}/api/sends/{send_id}/{file_id}?t={token}" , & host . host ) )
} else {
} else {
Ok ( operator . presign_read ( & format ! ( "{send_id}/{file_id}" ) , Duration ::from_secs ( 5 * 60 ) ) . await ? . uri ( ) . to_string ( ) )
Ok ( operator . presign_read ( & format ! ( "{send_id}/{file_id}" ) , Duration ::from_mins ( 5 ) ) . await ? . uri ( ) . to_string ( ) )
}
}
}
}
@ -38,7 +38,7 @@ static WEBAUTHN: LazyLock<Webauthn> = LazyLock::new(|| {
let webauthn = WebauthnBuilder ::new ( & rp_id , & rp_origin )
let webauthn = WebauthnBuilder ::new ( & rp_id , & rp_origin )
. expect ( "Creating WebauthnBuilder failed" )
. expect ( "Creating WebauthnBuilder failed" )
. rp_name ( & domain )
. rp_name ( & domain )
. timeout ( Duration ::from_millis ( 60000 ) ) ;
. timeout ( Duration ::from_mins ( 1 ) ) ;
webauthn . build ( ) . expect ( "Building Webauthn failed" )
webauthn . build ( ) . expect ( "Building Webauthn failed" )
} ) ;
} ) ;
@ -50,7 +50,7 @@ impl Attachment {
let token = encode_jwt ( & generate_file_download_claims ( self . cipher_uuid . clone ( ) , self . id . clone ( ) ) ) ;
let token = encode_jwt ( & generate_file_download_claims ( self . cipher_uuid . clone ( ) , self . id . clone ( ) ) ) ;
Ok ( format ! ( "{host}/attachments/{}/{}?token={token}" , self . cipher_uuid , self . id ) )
Ok ( format ! ( "{host}/attachments/{}/{}?token={token}" , self . cipher_uuid , self . id ) )
} else {
} else {
Ok ( operator . presign_read ( & self . get_file_path ( ) , Duration ::from_secs ( 5 * 60 ) ) . await ? . uri ( ) . to_string ( ) )
Ok ( operator . presign_read ( & self . get_file_path ( ) , Duration ::from_mins ( 5 ) ) . await ? . uri ( ) . to_string ( ) )
}
}
}
}
@ -734,7 +734,7 @@ where
warn ! ( "Can't connect to database, retrying: {e:?}" ) ;
warn ! ( "Can't connect to database, retrying: {e:?}" ) ;
sleep ( Duration ::from_milli s ( 1_000 ) ) . await ;
sleep ( Duration ::from_sec s ( 1 ) ) . await ;
}
}
}
}
}
}