cargo fmt + clippy

This commit is contained in:
nvrl committed 2026-06-28 11:41:51 +02:00
1 parent 70e573ebe1
commit c98ec2d55d
12 files changed
+52 -43

No files matched your search

+12 -12
View File
@@ -4,8 +4,8 @@ use std::collections::HashMap;
use std::io::{Cursor, Read};
use std::sync::Arc;
use base64::engine::general_purpose::STANDARD as BASE64;
use base64::Engine;
use base64::engine::general_purpose::STANDARD as BASE64;
use sha2::{Digest, Sha256};
use tokio::sync::Mutex;
@@ -13,8 +13,8 @@ use proton_sdk::account::AccountClient;
use proton_sdk::cache::{CacheRepository, InMemoryCacheRepository};
use proton_sdk::crypto::PrivateKey;
use proton_sdk::crypto::{
build_volume_creation_material, generate_node_hash_key, generate_node_key,
generate_node_key_aead, verify_detached, ContentKey, VerificationKeyRing, VerificationStatus,
ContentKey, VerificationKeyRing, VerificationStatus, build_volume_creation_material,
generate_node_hash_key, generate_node_key, generate_node_key_aead, verify_detached,
};
use proton_sdk::error::{ProtonError, Result};
use proton_sdk::http::ApiHttpClient;
@@ -2430,8 +2430,9 @@ impl ProtonDriveClient {
// leaves the claimed metadata absent rather than failing the node.
let mut claimed_size = None;
let mut claimed_modification_time = None;
if let Some(rev) = file.active_revision.as_ref() {
if let Some(xattr) = rev.extended_attributes.as_deref() {
if let Some(rev) = file.active_revision.as_ref()
&& let Some(xattr) = rev.extended_attributes.as_deref()
{
match decrypt_extended_attributes_verified(
&self.account,
&decrypted.node_key,
@@ -2452,7 +2453,6 @@ impl ProtonDriveClient {
}
}
}
}
NodeKind::File {
media_type: file.media_type.clone(),
total_size_on_storage: file.total_size_on_storage,
@@ -2520,11 +2520,11 @@ impl ProtonDriveClient {
uid: &NodeUid,
link: &LinkDto,
) -> Result<Option<String>> {
if let Some(info) = self.entities.try_get_node(uid).await? {
if !info.name_hash_digest.is_empty() {
if let Some(info) = self.entities.try_get_node(uid).await?
&& !info.name_hash_digest.is_empty()
{
return Ok(Some(info.name_hash_digest));
}
}
Ok(link.name_hash.clone())
}
@@ -2768,7 +2768,7 @@ fn verification_token(code: &[u8], ciphertext: &[u8]) -> Vec<u8> {
#[cfg(test)]
mod tests {
use super::{alternate_names, epoch_to_iso8601, to_drive_event, DriveEvent};
use super::{DriveEvent, alternate_names, epoch_to_iso8601, to_drive_event};
use crate::dtos::{VolumeEventDto, VolumeEventLinkDto};
use proton_sdk::ids::{DriveEventId, LinkId, VolumeId};
@@ -2866,7 +2866,7 @@ mod tests {
#[test]
fn photos_attributes_content_hash_and_tags() {
use super::{build_photos_attributes, hmac_sha256, BlockWriteResult};
use super::{BlockWriteResult, build_photos_attributes, hmac_sha256};
use crate::photos::{PhotoTag, PhotoUploadMetadata};
use proton_sdk::ids::NodeUid;
@@ -2902,7 +2902,7 @@ mod tests {
#[test]
fn photos_attributes_default_capture_time_and_empty_tags() {
use super::{build_photos_attributes, BlockWriteResult};
use super::{BlockWriteResult, build_photos_attributes};
use crate::photos::PhotoUploadMetadata;
let written = BlockWriteResult {
+2 -2
View File
@@ -6,8 +6,8 @@
use proton_sdk::account::AccountClient;
use proton_sdk::crypto::{
decrypt_armored_with_keys, verify_detached, ContentKey, PrivateKey, PublicKey,
VerificationKeyRing, VerificationStatus,
ContentKey, PrivateKey, PublicKey, VerificationKeyRing, VerificationStatus,
decrypt_armored_with_keys, verify_detached,
};
use proton_sdk::error::{ProtonError, Result};
+2 -2
View File
@@ -65,8 +65,8 @@ impl NodeVerification {
};
ok(self.name)
&& ok(self.passphrase)
&& self.content_key.map_or(true, ok)
&& self.extended_attributes.map_or(true, ok)
&& self.content_key.is_none_or(ok)
&& self.extended_attributes.is_none_or(ok)
}
}
+12 -6
View File
@@ -184,9 +184,12 @@ async fn node_creation_surfaces_node_updated() {
.await
.expect("create folder");
let found = poll_for(client, &scope, &cursor, |e| {
matches!(e, DriveEvent::NodeUpdated { node_uid, .. } if *node_uid == folder)
})
let found = poll_for(
client,
&scope,
&cursor,
|e| matches!(e, DriveEvent::NodeUpdated { node_uid, .. } if *node_uid == folder),
)
.await;
match found {
@@ -282,9 +285,12 @@ async fn permanent_delete_surfaces_node_deleted() {
.await
.expect("delete folder");
let found = poll_for(client, &scope, &cursor, |e| {
matches!(e, DriveEvent::NodeDeleted { node_uid, .. } if *node_uid == folder)
})
let found = poll_for(
client,
&scope,
&cursor,
|e| matches!(e, DriveEvent::NodeDeleted { node_uid, .. } if *node_uid == folder),
)
.await;
assert!(
found.is_some(),
+5 -5
View File
@@ -17,13 +17,13 @@ mod verify;
pub use content::ContentKey;
pub use derive::derive_key_passphrase;
pub use encrypt::{
build_volume_creation_material, generate_node_hash_key, generate_node_key,
generate_node_key_aead, GeneratedNodeKey, VolumeCreationMaterial,
GeneratedNodeKey, VolumeCreationMaterial, build_volume_creation_material,
generate_node_hash_key, generate_node_key, generate_node_key_aead,
};
pub use errors::CryptoError;
pub use keys::{decrypt_armored_with_keys, PrivateKey};
pub use srp::{generate_proofs, SrpProofs, DEFAULT_BIT_LENGTH};
pub use verify::{verify_detached, PublicKey, VerificationKeyRing, VerificationStatus};
pub use keys::{PrivateKey, decrypt_armored_with_keys};
pub use srp::{DEFAULT_BIT_LENGTH, SrpProofs, generate_proofs};
pub use verify::{PublicKey, VerificationKeyRing, VerificationStatus, verify_detached};
/// Result alias for crypto operations.
pub type CryptoResult<T> = std::result::Result<T, CryptoError>;
+3 -3
View File
@@ -19,7 +19,7 @@ use pgp::packet::{
};
use pgp::types::{DecryptionKey, EncryptionKey, EskType, PkeskVersion, Seipdv1ReadMode};
use super::encrypt::{recipient_encryption_key, RecipientOp};
use super::encrypt::{RecipientOp, recipient_encryption_key};
use super::errors::CryptoError;
use super::keys::PrivateKey;
@@ -246,7 +246,7 @@ impl ContentKey {
return Err(CryptoError::Parse(format!(
"unexpected thumbnail payload packet: {:?}",
other.tag()
)))
)));
}
}
}
@@ -276,7 +276,7 @@ impl ContentKey {
return Err(CryptoError::Parse(format!(
"unexpected block packet: {:?}",
other.tag()
)))
)));
}
}
};
+2 -3
View File
@@ -6,8 +6,8 @@
//! signing key with a separate encryption subkey, so recipient selection must
//! pick the encryption-capable (sub)key.
use base64::engine::general_purpose::STANDARD as BASE64;
use base64::Engine;
use base64::engine::general_purpose::STANDARD as BASE64;
use bytes::Bytes;
use pgp::composed::{
ArmorOptions, DetachedSignature, EncryptionCaps, KeyType, MessageBuilder,
@@ -278,8 +278,7 @@ pub(crate) fn sign_detached(signer: &PrivateKey, data: &[u8]) -> Result<String,
.map_err(|e| CryptoError::Encrypt(format!("creation-time subpacket: {e}")))?,
];
if key.version() <= KeyVersion::V4 {
config.unhashed_subpackets =
vec![
config.unhashed_subpackets = vec![
Subpacket::regular(SubpacketData::IssuerKeyId(key.legacy_key_id()))
.map_err(|e| CryptoError::Encrypt(format!("issuer subpacket: {e}")))?,
];
+1 -1
View File
@@ -4,7 +4,7 @@
//! distinct pre-unlock step, so a [`PrivateKey`] simply pairs a parsed
//! [`SignedSecretKey`] with the passphrase that unlocks it.
use pgp::composed::{Deserializable, SignedSecretKey, DetachedSignature};
use pgp::composed::{Deserializable, DetachedSignature, SignedSecretKey};
use pgp::types::Password;
use super::errors::CryptoError;
+1 -1
View File
@@ -11,8 +11,8 @@
//! message; we verify the signature against Proton's embedded SRP modulus key
//! before trusting it.
use base64::engine::general_purpose::STANDARD as BASE64;
use base64::Engine;
use base64::engine::general_purpose::STANDARD as BASE64;
use num_bigint::BigUint;
use num_traits::One;
use pgp::composed::{CleartextSignedMessage, Deserializable, SignedPublicKey};
+1 -1
View File
@@ -9,7 +9,7 @@
//! throwing.
use pgp::composed::{
Deserializable, Message, SignedPublicKey, SignedSecretKey, DetachedSignature,
Deserializable, DetachedSignature, Message, SignedPublicKey, SignedSecretKey,
VerificationResult,
};
use pgp::types::{Password, VerifyingKey};
+10 -6
View File
@@ -10,12 +10,12 @@ use std::time::Duration;
use rand::Rng;
use reqwest::{Method, StatusCode};
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde::de::DeserializeOwned;
use tokio::sync::Mutex;
use crate::api::{ApiResponse, ResponseCode};
use crate::config::{ProtonClientConfiguration, RetryPolicy, API_CONTENT_TYPE};
use crate::config::{API_CONTENT_TYPE, ProtonClientConfiguration, RetryPolicy};
use crate::error::{ProtonApiError, ProtonError, Result};
use crate::ids::SessionId;
use crate::telemetry::{NoopTelemetry, Telemetry, TelemetryExt};
@@ -674,13 +674,17 @@ mod tests {
let event = &events[0];
assert_eq!(event.operation, "http_request");
assert_eq!(event.outcome, Outcome::Success);
assert!(event
assert!(
event
.attributes
.iter()
.any(|(k, v)| *k == "method" && v == "GET"));
assert!(event
.any(|(k, v)| *k == "method" && v == "GET")
);
assert!(
event
.attributes
.iter()
.any(|(k, v)| *k == "status" && v == "200"));
.any(|(k, v)| *k == "status" && v == "200")
);
}
}
+1 -1
View File
@@ -6,8 +6,8 @@
//! deferred, matching the official SDK's stance that login flows live outside
//! the core Drive scope.
use base64::engine::general_purpose::STANDARD as BASE64;
use base64::Engine;
use base64::engine::general_purpose::STANDARD as BASE64;
use serde::{Deserialize, Serialize};
use crate::config::ProtonClientConfiguration;