mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 00:34:40 +01:00
Fix clippy warnings
This commit is contained in:
parent
07043dc272
commit
a3f3b327f8
10 changed files with 16 additions and 17 deletions
|
@ -136,7 +136,7 @@ impl Scrapper {
|
|||
}) => {
|
||||
let mut href = String::from_utf8(value.into_owned()).ok()?;
|
||||
if href.starts_with("//") {
|
||||
href = format!("https:{}", href);
|
||||
href = format!("https:{href}");
|
||||
}
|
||||
url = match Url::parse(&href) {
|
||||
Ok(url) => Some(url),
|
||||
|
@ -211,7 +211,7 @@ impl Scrapper {
|
|||
metadata.format = favicon_format;
|
||||
} else {
|
||||
if href.starts_with("//") {
|
||||
href = format!("https:{}", href);
|
||||
href = format!("https:{href}");
|
||||
}
|
||||
match Url::parse(&href) {
|
||||
Ok(url) => {
|
||||
|
|
|
@ -418,7 +418,7 @@ impl Application {
|
|||
|
||||
fn account_provider_by_identifier(&self, id: &str) -> Option<(Provider, Account)> {
|
||||
let identifier = id.split(':').collect::<Vec<&str>>();
|
||||
let provider_id = identifier.get(0)?.parse::<u32>().ok()?;
|
||||
let provider_id = identifier.first()?.parse::<u32>().ok()?;
|
||||
let account_id = identifier.get(1)?.parse::<u32>().ok()?;
|
||||
|
||||
let provider = self.imp().model.find_by_id(provider_id)?;
|
||||
|
|
|
@ -321,7 +321,7 @@ impl Item {
|
|||
|
||||
pub fn fix_empty_issuer(&mut self) -> Result<()> {
|
||||
if self.issuer.is_none() {
|
||||
let mut vals: Vec<&str> = self.label.split("@").collect();
|
||||
let mut vals: Vec<&str> = self.label.split('@').collect();
|
||||
if vals.len() > 1 {
|
||||
self.issuer = vals.pop().map(ToOwned::to_owned);
|
||||
self.label = vals.join("@");
|
||||
|
@ -583,7 +583,7 @@ impl Restorable for Aegis {
|
|||
};
|
||||
|
||||
// Try to decrypt the database with this master key.
|
||||
let cipher = aes_gcm::Aes256Gcm::new_from_slice(&master_key)?;
|
||||
let cipher = aes_gcm::Aes256Gcm::new_from_slice(master_key)?;
|
||||
let plaintext = cipher
|
||||
.decrypt(
|
||||
aes_gcm::Nonce::from_slice(
|
||||
|
@ -703,7 +703,7 @@ mod tests {
|
|||
let result = Aegis::restore_from_data(&aegis_data.as_bytes(), None).unwrap_err();
|
||||
|
||||
assert_eq!(
|
||||
format!("{}", result),
|
||||
format!("{result}"),
|
||||
"Entry cannot-derive-issuer-value has an empty issuer"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ impl Restorable for Google {
|
|||
folded.or_else(|| match key.into_owned().as_str() {
|
||||
"data" => {
|
||||
let bytes = value.into_owned().into_bytes();
|
||||
let decoded = percent_decode(&*bytes);
|
||||
let decoded = percent_decode(&bytes);
|
||||
let decoded = match base64::decode(&*Cow::from(decoded)) {
|
||||
Ok(decoded) => decoded,
|
||||
Err(_) => return None,
|
||||
|
|
|
@ -40,7 +40,7 @@ pub trait Restorable: Sized {
|
|||
/// `Self::restore_from_data`.
|
||||
fn restore_from_file(from: &gio::File, key: Option<&str>) -> Result<Vec<Self::Item>> {
|
||||
let (data, _) = from.load_contents(gio::Cancellable::NONE)?;
|
||||
Self::restore_from_data(&*data, key)
|
||||
Self::restore_from_data(&data, key)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ impl Account {
|
|||
let db = database::connection();
|
||||
let mut conn = db.get()?;
|
||||
|
||||
let label = format!("{} - {}", provider.name(), name);
|
||||
let label = format!("{} - {name}", provider.name());
|
||||
let token_send = token.to_owned();
|
||||
let token_id = spawn_tokio_blocking(async move {
|
||||
keyring::store(&label, &token_send)
|
||||
|
|
|
@ -17,11 +17,10 @@ pub(crate) fn connection() -> Pool {
|
|||
}
|
||||
|
||||
fn init_pool() -> Result<Pool> {
|
||||
let db_path = &DB_PATH;
|
||||
fs::create_dir_all(&db_path.to_str().unwrap())?;
|
||||
let db_path = db_path.join("authenticator.db");
|
||||
fs::create_dir_all(&*DB_PATH)?;
|
||||
let db_path = DB_PATH.join("authenticator.db");
|
||||
if !db_path.exists() {
|
||||
File::create(&db_path.to_str().unwrap())?;
|
||||
File::create(&db_path)?;
|
||||
}
|
||||
let manager = ConnectionManager::<SqliteConnection>::new(db_path.to_str().unwrap());
|
||||
let pool = r2d2::Pool::builder().build(manager)?;
|
||||
|
|
|
@ -106,7 +106,7 @@ pub async fn is_current_password(password: &str) -> anyhow::Result<bool> {
|
|||
// Verifies that the hash generated by `password` corresponds
|
||||
// to `hash`.
|
||||
argon2::verify_encoded(
|
||||
&String::from_utf8_lossy(&*i.secret().await?),
|
||||
&String::from_utf8_lossy(&i.secret().await?),
|
||||
password.as_bytes(),
|
||||
)?
|
||||
}
|
||||
|
|
|
@ -83,10 +83,10 @@ impl TryFrom<Url> for OTPUri {
|
|||
.collect::<Vec<&str>>();
|
||||
|
||||
let account_name = if account_info.len() == 1 {
|
||||
account_info.get(0).unwrap()
|
||||
account_info.first().unwrap()
|
||||
} else {
|
||||
// If we have "Provider:Account"
|
||||
provider_name = Some(account_info.get(0).unwrap().to_string());
|
||||
provider_name = Some(account_info.first().unwrap().to_string());
|
||||
account_info.get(1).unwrap()
|
||||
};
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ impl Provider {
|
|||
let favicon = favicon_scrapper::Scrapper::from_url(website_url).await?;
|
||||
tracing::debug!("Found the following icons {:#?} for {}", favicon, name);
|
||||
|
||||
let icon_name = format!("{}_{}", id, name.replace(' ', "_"));
|
||||
let icon_name = format!("{id}_{}", name.replace(' ', "_"));
|
||||
let icon_name = glib::base64_encode(icon_name.as_bytes());
|
||||
let small_icon_name = format!("{icon_name}_32x32");
|
||||
let large_icon_name = format!("{icon_name}_96x96");
|
||||
|
|
Loading…
Add table
Reference in a new issue