Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
};

# Use specific rust version required by Tauri
rustToolchain = pkgs.rust-bin.stable."1.85.0".default.override {
rustToolchain = pkgs.rust-bin.stable."1.88.0".default.override {
extensions = [ "rust-src" ];
};
in
Expand Down
2 changes: 1 addition & 1 deletion frontend/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["tony@opensecret.cloud"]
license = "MIT"
repository = "https://github.com/OpenSecretCloud/Maple"
edition = "2021"
rust-version = "1.77.2"
rust-version = "1.88.0"
Comment thread
AnthonyRonning marked this conversation as resolved.

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
36 changes: 18 additions & 18 deletions frontend/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ fn restart_for_update(app_handle: tauri::AppHandle) {

// This handles incoming deep links
fn handle_deep_link_event(url: &str, app: &tauri::AppHandle) {
log::info!("[Deep Link] Received: {}", url);
log::info!("[Deep Link] Received: {url}");
// Forward the URL to the frontend
match app.emit_to("main", "deep-link-received", url.to_string()) {
Ok(_) => log::info!("[Deep Link] Event emitted successfully"),
Err(e) => log::error!("[Deep Link] Failed to emit event: {}", e),
Err(e) => log::error!("[Deep Link] Failed to emit event: {e}"),
}
}

Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn run() {

// Create a new State wrapper for the async context
if let Err(e) = proxy::init_proxy_on_startup_simple(app_handle_proxy).await {
log::error!("Failed to initialize proxy: {}", e);
log::error!("Failed to initialize proxy: {e}");
}
});
}
Expand All @@ -81,7 +81,7 @@ pub fn run() {
// Optionally register the scheme at runtime
#[cfg(desktop)]
if let Err(e) = app.deep_link().register("cloud.opensecret.maple") {
log::error!("[Deep Link] Failed to register scheme: {}", e);
log::error!("[Deep Link] Failed to register scheme: {e}");
}
// Create the application menu with update options
#[cfg(desktop)]
Expand Down Expand Up @@ -216,7 +216,7 @@ pub fn run() {
{
match CURRENT_VERSION.lock() {
Ok(mut version) => version.clear(),
Err(e) => log::error!("Failed to lock CURRENT_VERSION mutex when clearing: {}", e)
Err(e) => log::error!("Failed to lock CURRENT_VERSION mutex when clearing: {e}")
}
}
log::info!("Dismissal flags cleared - user will be prompted for any available updates");
Expand All @@ -228,7 +228,7 @@ pub fn run() {
tauri::async_runtime::spawn(async move {
match check_for_updates(app_handle_clone).await {
Ok(_) => log::info!("Update check completed successfully"),
Err(e) => log::error!("Update check failed: {}", e),
Err(e) => log::error!("Update check failed: {e}"),
}
});
}
Expand Down Expand Up @@ -307,8 +307,8 @@ async fn check_for_updates(app_handle: tauri::AppHandle) -> Result<(), String> {
let updater = match app_handle.updater() {
Ok(u) => u,
Err(e) => {
log::error!("Failed to get updater: {}", e);
return Err(format!("Failed to get updater: {}", e));
log::error!("Failed to get updater: {e}");
return Err(format!("Failed to get updater: {e}"));
}
};

Expand All @@ -319,7 +319,7 @@ async fn check_for_updates(app_handle: tauri::AppHandle) -> Result<(), String> {
let current_downloaded_version = match CURRENT_VERSION.lock() {
Ok(guard) => guard.clone(),
Err(e) => {
log::error!("Failed to lock CURRENT_VERSION mutex: {}", e);
log::error!("Failed to lock CURRENT_VERSION mutex: {e}");
String::new() // Use empty string if lock fails
}
};
Expand All @@ -339,9 +339,9 @@ async fn check_for_updates(app_handle: tauri::AppHandle) -> Result<(), String> {
// Download the update
let progress_fn = |downloaded: usize, total: Option<u64>| {
if let Some(total) = total {
log::info!("Download progress: {}/{} bytes", downloaded, total);
log::info!("Download progress: {downloaded}/{total} bytes");
} else {
log::info!("Download progress: {} bytes", downloaded);
log::info!("Download progress: {downloaded} bytes");
}
};

Expand All @@ -364,7 +364,7 @@ async fn check_for_updates(app_handle: tauri::AppHandle) -> Result<(), String> {
{
match CURRENT_VERSION.lock() {
Ok(mut version) => *version = update.version.clone(),
Err(e) => log::error!("Failed to lock CURRENT_VERSION mutex when updating version: {}", e)
Err(e) => log::error!("Failed to lock CURRENT_VERSION mutex when updating version: {e}")
}
}

Expand All @@ -391,7 +391,7 @@ async fn check_for_updates(app_handle: tauri::AppHandle) -> Result<(), String> {
version: update.version.clone(),
},
) {
log::error!("Failed to emit update-ready event: {}", e);
log::error!("Failed to emit update-ready event: {e}");
} else {
log::info!(
"Emitted update-ready event for version {}",
Expand All @@ -400,15 +400,15 @@ async fn check_for_updates(app_handle: tauri::AppHandle) -> Result<(), String> {
}
}
Err(e) => {
log::error!("Failed to install update: {}", e);
log::error!("Failed to install update: {e}");
}
}

Ok(())
}
Err(e) => {
log::error!("Failed to download update: {}", e);
Err(format!("Failed to download update: {}", e))
log::error!("Failed to download update: {e}");
Err(format!("Failed to download update: {e}"))
}
}
}
Expand All @@ -417,8 +417,8 @@ async fn check_for_updates(app_handle: tauri::AppHandle) -> Result<(), String> {
Ok(())
}
Err(e) => {
log::error!("Failed to check for updates: {}", e);
Err(format!("Failed to check for updates: {}", e))
log::error!("Failed to check for updates: {e}");
Err(format!("Failed to check for updates: {e}"))
}
}
}
9 changes: 4 additions & 5 deletions frontend/src-tauri/src/pdf_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ pub async fn extract_document_content(
// Decode base64 file data
let file_bytes = BASE64
.decode(&file_base64)
.map_err(|e| format!("Failed to decode base64 file: {}", e))?;
.map_err(|e| format!("Failed to decode base64 file: {e}"))?;

let text_content = match file_type.as_str() {
"pdf" | "application/pdf" => {
// Extract text from PDF
extract_text_from_mem(&file_bytes)
.map_err(|e| format!("Failed to extract text from PDF: {}", e))?
.map_err(|e| format!("Failed to extract text from PDF: {e}"))?
}
"txt" | "text/plain" | "md" | "text/markdown" => {
// For text files, just convert bytes to string
String::from_utf8(file_bytes)
.map_err(|e| format!("Failed to decode text file: {}", e))?
String::from_utf8(file_bytes).map_err(|e| format!("Failed to decode text file: {e}"))?
}
_ => {
return Err(format!("Unsupported file type: {}", file_type));
return Err(format!("Unsupported file type: {file_type}"));
}
};

Expand Down
18 changes: 9 additions & 9 deletions frontend/src-tauri/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub async fn start_proxy(
// Try to bind to the address first to check if port is available
let addr = proxy_config
.socket_addr()
.map_err(|e| format!("Invalid address: {}", e))?;
.map_err(|e| format!("Invalid address: {e}"))?;

let listener = match TcpListener::bind(&addr).await {
Ok(listener) => listener,
Expand All @@ -118,9 +118,9 @@ pub async fn start_proxy(

// Spawn the proxy server
let handle = tokio::spawn(async move {
log::info!("Maple proxy server running on http://{}", addr);
log::info!("Maple proxy server running on http://{addr}");
if let Err(e) = axum::serve(listener, app).await {
log::error!("Proxy server error: {}", e);
log::error!("Proxy server error: {e}");
}
});

Expand All @@ -133,7 +133,7 @@ pub async fn start_proxy(

// Save config to disk
if let Err(e) = save_proxy_config(&config).await {
log::error!("Failed to save proxy config: {}", e);
log::error!("Failed to save proxy config: {e}");
}

Ok(ProxyStatus {
Expand Down Expand Up @@ -188,27 +188,27 @@ pub async fn get_proxy_status(state: State<'_, ProxyState>) -> Result<ProxyStatu
pub async fn load_proxy_config() -> Result<ProxyConfig, String> {
load_saved_proxy_config()
.await
.map_err(|e| format!("Failed to load proxy config: {}", e))
.map_err(|e| format!("Failed to load proxy config: {e}"))
}

#[tauri::command]
pub async fn save_proxy_settings(config: ProxyConfig) -> Result<(), String> {
save_proxy_config(&config)
.await
.map_err(|e| format!("Failed to save proxy config: {}", e))
.map_err(|e| format!("Failed to save proxy config: {e}"))
}

#[tauri::command]
pub async fn test_proxy_port(host: String, port: u16) -> Result<bool, String> {
// Try to bind to the address to check if it's available
let addr = format!("{}:{}", host, port);
let addr = format!("{host}:{port}");
match TcpListener::bind(&addr).await {
Ok(_) => Ok(true), // Port is available
Err(e) => {
if e.kind() == std::io::ErrorKind::AddrInUse {
Ok(false) // Port is in use
} else {
Err(format!("Failed to test port: {}", e))
Err(format!("Failed to test port: {e}"))
}
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ pub async fn init_proxy_on_startup_simple(app_handle: AppHandle) -> Result<()> {
let _ = app_handle.emit("proxy-autostarted", &config);
}
Err(e) => {
log::error!("Failed to auto-start proxy: {}", e);
log::error!("Failed to auto-start proxy: {e}");
// Emit an event to notify the frontend of the failure
let _ = app_handle.emit("proxy-autostart-failed", e);
}
Expand Down
Loading
Loading