mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-14 08:41:21 +10:00
Clippy CI/CD (#67)
* feat: add clippy ci * fix: clippy errors * fix: ci/cd * fix: update ci packages * fix: add gtk3 to ci deps * fix: add webkit to ci deps * fix: ci deps and perms * fix: add clippy settings to lib.rs
This commit is contained in:
@ -72,7 +72,7 @@ pub fn fetch_user() -> Result<User, RemoteAccessError> {
|
||||
.send()?;
|
||||
if response.status() != 200 {
|
||||
let err: DropServerError = response.json()?;
|
||||
warn!("{:?}", err);
|
||||
warn!("{err:?}");
|
||||
|
||||
if err.status_message == "Nonce expired" {
|
||||
return Err(RemoteAccessError::OutOfSync);
|
||||
@ -148,7 +148,7 @@ pub fn recieve_handshake(app: AppHandle, path: String) {
|
||||
|
||||
let handshake_result = recieve_handshake_logic(&app, path);
|
||||
if let Err(e) = handshake_result {
|
||||
warn!("error with authentication: {}", e);
|
||||
warn!("error with authentication: {e}");
|
||||
app.emit("auth/failed", e.to_string()).unwrap();
|
||||
return;
|
||||
}
|
||||
@ -212,7 +212,7 @@ pub fn setup() -> (AppStatus, Option<User>) {
|
||||
let user_result = match fetch_user() {
|
||||
Ok(data) => data,
|
||||
Err(RemoteAccessError::FetchError(_)) => {
|
||||
let user = get_cached_object::<String, User>("user".to_owned()).unwrap();
|
||||
let user = get_cached_object::<_, User>("user").unwrap();
|
||||
return (AppStatus::Offline, Some(user));
|
||||
}
|
||||
Err(_) => return (AppStatus::SignedInNeedsReauth, None),
|
||||
|
||||
@ -11,7 +11,7 @@ use serde_binary::binary_stream::Endian;
|
||||
macro_rules! offline {
|
||||
($var:expr, $func1:expr, $func2:expr, $( $arg:expr ),* ) => {
|
||||
|
||||
if crate::borrow_db_checked().settings.force_offline || $var.lock().unwrap().status == crate::AppStatus::Offline {
|
||||
if $crate::borrow_db_checked().settings.force_offline || $var.lock().unwrap().status == $crate::AppStatus::Offline {
|
||||
$func2( $( $arg ), *)
|
||||
} else {
|
||||
$func1( $( $arg ), *)
|
||||
@ -19,24 +19,24 @@ macro_rules! offline {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cache_object<'a, K: AsRef<str>, D: Serialize + DeserializeOwned>(
|
||||
pub fn cache_object<K: AsRef<str>, D: Serialize + DeserializeOwned>(
|
||||
key: K,
|
||||
data: &D,
|
||||
) -> Result<Integrity, RemoteAccessError> {
|
||||
let bytes = serde_binary::to_vec(data, Endian::Little).unwrap();
|
||||
cacache::write_sync(&borrow_db_checked().cache_dir, key, bytes)
|
||||
.map_err(|e| RemoteAccessError::Cache(e))
|
||||
.map_err(RemoteAccessError::Cache)
|
||||
}
|
||||
pub fn get_cached_object<'a, K: AsRef<str>, D: Serialize + DeserializeOwned>(
|
||||
pub fn get_cached_object<K: AsRef<str>, D: Serialize + DeserializeOwned>(
|
||||
key: K,
|
||||
) -> Result<D, RemoteAccessError> {
|
||||
get_cached_object_db::<K, D>(key, &borrow_db_checked())
|
||||
}
|
||||
pub fn get_cached_object_db<'a, K: AsRef<str>, D: Serialize + DeserializeOwned>(
|
||||
pub fn get_cached_object_db<K: AsRef<str>, D: Serialize + DeserializeOwned>(
|
||||
key: K,
|
||||
db: &Database,
|
||||
) -> Result<D, RemoteAccessError> {
|
||||
let bytes = cacache::read_sync(&db.cache_dir, key).map_err(|e| RemoteAccessError::Cache(e))?;
|
||||
let bytes = cacache::read_sync(&db.cache_dir, key).map_err(RemoteAccessError::Cache)?;
|
||||
let data = serde_binary::from_slice::<D>(&bytes, Endian::Little).unwrap();
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ use crate::{
|
||||
use super::{
|
||||
auth::{auth_initiate_logic, recieve_handshake, setup},
|
||||
cache::{cache_object, get_cached_object},
|
||||
remote::use_remote_logic,
|
||||
utils::use_remote_logic,
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
@ -54,7 +54,7 @@ pub fn fetch_drop_object(path: String) -> Result<Vec<u8>, RemoteAccessError> {
|
||||
Ok(data)
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("{}", e);
|
||||
debug!("{e}");
|
||||
get_cached_object::<&str, Vec<u8>>(&path)
|
||||
}
|
||||
}
|
||||
@ -96,5 +96,5 @@ pub fn auth_initiate() -> Result<(), RemoteAccessError> {
|
||||
|
||||
#[tauri::command]
|
||||
pub fn manual_recieve_handshake(app: AppHandle, token: String) {
|
||||
recieve_handshake(app, format!("handshake/{}", token));
|
||||
recieve_handshake(app, format!("handshake/{token}"));
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ pub fn fetch_object(request: http::Request<Vec<u8>>, responder: UriSchemeRespond
|
||||
match data {
|
||||
Ok(data) => responder.respond(data.into()),
|
||||
Err(e) => {
|
||||
warn!("{}", e)
|
||||
warn!("{e}")
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -48,6 +48,6 @@ pub fn fetch_object_offline(request: http::Request<Vec<u8>>, responder: UriSchem
|
||||
|
||||
match data {
|
||||
Ok(data) => responder.respond(data.into()),
|
||||
Err(e) => warn!("{}", e),
|
||||
Err(e) => warn!("{e}"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,6 @@ pub mod auth;
|
||||
pub mod cache;
|
||||
pub mod commands;
|
||||
pub mod fetch_object;
|
||||
pub mod remote;
|
||||
pub mod utils;
|
||||
pub mod requests;
|
||||
pub mod server_proto;
|
||||
|
||||
@ -26,17 +26,16 @@ pub fn handle_server_proto(request: Request<Vec<u8>>, responder: UriSchemeRespon
|
||||
|
||||
let mut new_uri = request.uri().clone().into_parts();
|
||||
new_uri.path_and_query =
|
||||
Some(PathAndQuery::from_str(&format!("{}?noWrapper=true", path)).unwrap());
|
||||
Some(PathAndQuery::from_str(&format!("{path}?noWrapper=true")).unwrap());
|
||||
new_uri.authority = remote_uri.authority().cloned();
|
||||
new_uri.scheme = remote_uri.scheme().cloned();
|
||||
let new_uri = Uri::from_parts(new_uri).unwrap();
|
||||
|
||||
let whitelist_prefix = vec!["/store", "/api", "/_", "/fonts"];
|
||||
let whitelist_prefix = ["/store", "/api", "/_", "/fonts"];
|
||||
|
||||
if whitelist_prefix
|
||||
.iter()
|
||||
.map(|f| !path.starts_with(f))
|
||||
.all(|f| f)
|
||||
.all(|f| !path.starts_with(f))
|
||||
{
|
||||
webbrowser::open(&new_uri.to_string()).unwrap();
|
||||
return;
|
||||
@ -45,7 +44,7 @@ pub fn handle_server_proto(request: Request<Vec<u8>>, responder: UriSchemeRespon
|
||||
let client = Client::new();
|
||||
let response = client
|
||||
.request(request.method().clone(), new_uri.to_string())
|
||||
.header("Authorization", format!("Bearer {}", web_token))
|
||||
.header("Authorization", format!("Bearer {web_token}"))
|
||||
.headers(request.headers().clone())
|
||||
.send()
|
||||
.unwrap();
|
||||
|
||||
@ -19,7 +19,7 @@ pub fn use_remote_logic(
|
||||
url: String,
|
||||
state: tauri::State<'_, Mutex<AppState<'_>>>,
|
||||
) -> Result<(), RemoteAccessError> {
|
||||
debug!("connecting to url {}", url);
|
||||
debug!("connecting to url {url}");
|
||||
let base_url = Url::parse(&url)?;
|
||||
|
||||
// Test Drop url
|
||||
Reference in New Issue
Block a user