mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-21 07:51:39 +01:00
Proxy storage: flows table, bodies in blobs.sqlite, settings (#751)
This commit is contained in:
1 parent
694c0272cd
commit
b5508e6bb1
25 files changed
+942
-289
No files matched your search
@@ -10,7 +10,7 @@ mod version_check;
|
||||
use clap::{CommandFactory, FromArgMatches};
|
||||
use cli::{AGENT_HINTS, Cli, Commands, PluginCommands, RequestCommands};
|
||||
use context::{CliContext, CliExecutionContext};
|
||||
use std::path::PathBuf;
|
||||
use yaak_common::data_dir::resolve_data_dir;
|
||||
use yaak_models::queries::any_request::AnyRequest;
|
||||
|
||||
/// Built at runtime so root `--help` can report whether the installed agent skill is
|
||||
@@ -286,46 +286,3 @@ fn resolve_cookie_jar_id(
|
||||
.map(|jar| jar.id);
|
||||
Ok(default_cookie_jar)
|
||||
}
|
||||
|
||||
fn resolve_data_dir(app_id: &str) -> PathBuf {
|
||||
if let Some(dir) = wsl_data_dir(app_id) {
|
||||
return dir;
|
||||
}
|
||||
dirs::data_dir().expect("Could not determine data directory").join(app_id)
|
||||
}
|
||||
|
||||
/// Detect WSL and resolve the Windows AppData\Roaming path for the Yaak data directory.
|
||||
fn wsl_data_dir(app_id: &str) -> Option<PathBuf> {
|
||||
if !cfg!(target_os = "linux") {
|
||||
return None;
|
||||
}
|
||||
|
||||
let proc_version = std::fs::read_to_string("/proc/version").ok()?;
|
||||
let is_wsl = proc_version.to_lowercase().contains("microsoft");
|
||||
if !is_wsl {
|
||||
return None;
|
||||
}
|
||||
|
||||
// We're in WSL, so try to resolve the Yaak app's data directory in Windows
|
||||
|
||||
// Get the Windows %APPDATA% path via cmd.exe
|
||||
let appdata_output =
|
||||
std::process::Command::new("cmd.exe").args(["/C", "echo", "%APPDATA%"]).output().ok()?;
|
||||
|
||||
let win_path = String::from_utf8(appdata_output.stdout).ok()?.trim().to_string();
|
||||
if win_path.is_empty() || win_path == "%APPDATA%" {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Convert Windows path to WSL path using wslpath (handles custom mount points)
|
||||
let wslpath_output = std::process::Command::new("wslpath").arg(&win_path).output().ok()?;
|
||||
|
||||
let wsl_appdata = String::from_utf8(wslpath_output.stdout).ok()?.trim().to_string();
|
||||
if wsl_appdata.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let wsl_path = PathBuf::from(wsl_appdata).join(app_id);
|
||||
|
||||
if wsl_path.exists() { Some(wsl_path) } else { None }
|
||||
}
|
||||
Reference in new issue
Block a user