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
106 changes: 106 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ oo7 = "0.6"
chrono = "0.4"
cairo-rs = { version = "0.22", features = ["use_glib"] }
serde_json = "1.0.149"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }

[profile.release]
opt-level = 3
Expand Down
27 changes: 13 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,37 @@ mod sftp_engine;

use gtk4::prelude::*;
use crate::ui::window::build_ui;
use std::fs::OpenOptions;
use std::io::Write;

use std::os::unix::fs::OpenOptionsExt;

fn log_debug(msg: &str) {
if let Ok(mut file) = OpenOptions::new().create(true).append(true).mode(0o600).open("/tmp/rustmius_debug.log") {
let _ = writeln!(file, "[{}] {}", chrono::Local::now(), msg);
}
}
use tracing::{debug, info, error};

#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env()
.add_directive(tracing::Level::INFO.into())
.add_directive("rustmius=debug".parse().unwrap()))
.init();

info!("Starting Rustmius v{}", env!("CARGO_PKG_VERSION"));

let _args: Vec<String> = std::env::args().collect();
if let Ok(alias) = std::env::var("RUSTMIUS_ASKPASS_ALIAS") {
log_debug(&format!("AskPass triggered for alias: {}", alias));
debug!("AskPass triggered for alias: {}", alias);
if let Ok(keyring) = oo7::Keyring::new().await {
let mut attributes = std::collections::HashMap::new();
let normalized_alias = alias.to_lowercase();
attributes.insert("rustmius-server-alias", normalized_alias.as_str());
if let Ok(items) = keyring.search_items(&attributes).await {
log_debug(&format!("Found {} items in keyring", items.len()));
debug!("Found {} items in keyring", items.len());
if let Some(item) = items.first()
&& let Ok(password) = item.secret().await
&& let Ok(pass_str) = std::str::from_utf8(password.as_ref()) {
log_debug("Password retrieved successfully, sending to SSH");
debug!("Password retrieved successfully, sending to SSH");
print!("{}", pass_str);
std::process::exit(0);
}
}
}
log_debug("Failed to retrieve password from keyring");
error!("Failed to retrieve password from keyring for alias: {}", alias);
std::process::exit(1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/file_explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl FileExplorer {

let h_drop = explorer.clone_handle();
drop_target.connect_drop(move |_, value, _, _| {
println!("Drop event received!");
tracing::debug!("Drop event received!");
let h = h_drop.clone();
let remote_dir = h.current_path.borrow().clone();
let mut paths: Vec<std::path::PathBuf> = Vec::new();
Expand All @@ -154,7 +154,7 @@ impl FileExplorer {
}

let count = paths.len();
println!("Starting upload of {} files", count);
tracing::debug!("Starting upload of {} files", count);
h.status_label.set_text(&format!("Uploading {} file(s)...", count));

for local_path in paths {
Expand Down