feat: add cli option to open executable files

feat/type-attributes
Tomáš Mládek 2022-10-18 18:19:01 +02:00
parent 9a9e0274fd
commit c87304602d
3 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,7 @@
pub struct UpEndConfig {
pub vault_name: Option<String>,
pub desktop_enabled: bool,
pub trust_executables: bool,
pub secret: String,
pub key: Option<String>,
}

View File

@ -72,6 +72,11 @@ fn main() -> Result<()> {
.long("no-desktop")
.help("Disable desktop features (webbrowser, native file opening)"),
)
.arg(
Arg::with_name("TRUST_EXECUTABLES")
.long("trust-executables")
.help("Trust the vault and open local executable files."),
)
.arg(
Arg::with_name("NO_UI")
.long("no-ui")
@ -144,6 +149,7 @@ fn main() -> Result<()> {
);
}
let desktop_enabled = !matches.is_present("NO_DESKTOP");
let trust_executables = matches.is_present("TRUST_EXECUTABLES");
let ui_enabled = ui_path.is_ok() && !matches.is_present("NO_UI");
let browser_enabled = desktop_enabled && !matches.is_present("NO_BROWSER");
@ -218,6 +224,7 @@ fn main() -> Result<()> {
}),
),
desktop_enabled,
trust_executables,
secret,
key,
},

View File

@ -160,7 +160,7 @@ pub async fn get_raw(
{
info!("Opening {:?}...", file_path);
let mut response = HttpResponse::NoContent();
let path = if !file_path.is_executable() {
let path = if !file_path.is_executable() || state.config.trust_executables {
file_path
} else {
response