From 3053d6702541a96cd33b0abc072a214219009061 Mon Sep 17 00:00:00 2001 From: Raylea <101520596+Ray-lea@users.noreply.github.com> Date: Sat, 21 Nov 2026 15:51:03 -0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(host):=20=E9=87=8D=E6=96=B0=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=91=BD=E4=BB=A4=E9=80=82=E9=85=8D=E5=99=A8=E6=97=B6?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E6=81=A2=E5=A4=8D=E9=BB=98=E8=AE=A4=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E7=9B=AE=E5=BD=95=E7=9A=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: bronyaicu <264752859+bronyaicu@users.noreply.github.com> --- src-gpui/src/commands.rs | 7 +++++ src-gpui/src/dispatch.rs | 63 ++++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src-gpui/src/commands.rs b/src-gpui/src/commands.rs index 04c9581a..6370aba1 100644 --- a/src-gpui/src/commands.rs +++ b/src-gpui/src/commands.rs @@ -1015,6 +1015,13 @@ pub fn history_move( Ok(settings_view(&app)) } +pub fn history_reset_dir( + app: crate::native_runtime::Host, + move_records: bool, +) -> Result { + history_move(app, String::new(), move_records) +} + pub fn history_open_dir(dir: State<'_, HistoryDir>) -> Result<(), String> { open_folder(&dir.read()).map_err(|_| tr!("history.error.open")) } diff --git a/src-gpui/src/dispatch.rs b/src-gpui/src/dispatch.rs index 7e701c48..af6bc606 100644 --- a/src-gpui/src/dispatch.rs +++ b/src-gpui/src/dispatch.rs @@ -14,10 +14,6 @@ fn argument(args: &Value, key: &str) -> Result) -> Result { - serde_json::to_value(result.map_err(Value::String)?) - .map_err(|_| Value::String(argus_core::tr!("app.invalidRequest"))) -} pub fn invoke(host: &Host, name: &str, args: Value) -> Result { match name { "desktop_shell" => Ok(serde_json::to_value(crate::commands::desktop_shell()) @@ -301,15 +297,13 @@ pub fn invoke(host: &Host, name: &str, args: Value) -> Result { argument::>(&args, "keys")?, )) .expect("serializable command response")), - "history_events" => serde_json::to_value( - crate::commands::history_events( - host.state(), - argument::(&args, "from")?, - argument::(&args, "to")?, - ) - .map_err(Value::String)?, + "history_events" => crate::commands::history_events( + host.state(), + argument::(&args, "from")?, + argument::(&args, "to")?, ) - .map_err(|_| Value::String(argus_core::tr!("app.invalidRequest"))), + .map(|value| serde_json::to_value(value).expect("serializable command response")) + .map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)), "history_channels" => Ok(serde_json::to_value(crate::commands::history_channels( host.state(), argument::(&args, "from")?, @@ -347,29 +341,36 @@ pub fn invoke(host: &Host, name: &str, args: Value) -> Result { ) .map(|value| serde_json::to_value(value).expect("serializable command response")) .map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)), - "history_move" => history_settings(crate::commands::history_move( + "set_history_enabled" => crate::commands::set_history_enabled( host.clone(), - argument(&args, "dir")?, - argument(&args, "moveRecords")?, - )), - "history_reset_dir" => history_settings(crate::commands::history_move( + host.state(), + host.state(), + argument::(&args, "enabled")?, + ) + .map(|value| serde_json::to_value(value).expect("serializable command response")) + .map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)), + "set_history_options" => crate::commands::set_history_options( host.clone(), - String::new(), - argument(&args, "moveRecords")?, - )), - "history_open_dir" => crate::commands::history_open_dir(host.state()) - .map(|()| Value::Null) - .map_err(Value::String), - "set_history_options" => history_settings(crate::commands::set_history_options( + argument::(&args, "options")?, + ) + .map(|value| serde_json::to_value(value).expect("serializable command response")) + .map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)), + "history_move" => crate::commands::history_move( host.clone(), - argument(&args, "options")?, - )), - "set_history_enabled" => history_settings(crate::commands::set_history_enabled( + argument::(&args, "dir")?, + argument::(&args, "moveRecords")?, + ) + .map(|value| serde_json::to_value(value).expect("serializable command response")) + .map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)), + "history_reset_dir" => crate::commands::history_reset_dir( host.clone(), - host.state(), - host.state(), - argument(&args, "enabled")?, - )), + argument::(&args, "moveRecords")?, + ) + .map(|value| serde_json::to_value(value).expect("serializable command response")) + .map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)), + "history_open_dir" => crate::commands::history_open_dir(host.state()) + .map(|value| serde_json::to_value(value).expect("serializable command response")) + .map_err(|error| serde_json::to_value(error).unwrap_or(serde_json::Value::Null)), "set_kernel_sensors" => crate::commands::set_kernel_sensors( host.clone(), host.state(), From e941e0e5073f71d012e632937c495fa37c439e34 Mon Sep 17 00:00:00 2001 From: Raylea <101520596+Ray-lea@users.noreply.github.com> Date: Sat, 21 Nov 2026 16:20:00 -0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(core):=20=E5=88=A0=E9=99=A4=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=96=87=E4=BB=B6=E5=89=8D=E6=A0=B8=E5=AF=B9=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E8=BF=9B=E7=A8=8B=E7=9A=84=E5=88=A0=E9=99=A4=E6=9D=83?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: bronyaicu <264752859+bronyaicu@users.noreply.github.com> --- crates/argus-core/src/startup.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/argus-core/src/startup.rs b/crates/argus-core/src/startup.rs index 6c66dd62..eb7f0a35 100644 --- a/crates/argus-core/src/startup.rs +++ b/crates/argus-core/src/startup.rs @@ -3,12 +3,13 @@ mod packaged; -use std::path::Path; +use std::{io::ErrorKind, os::windows::fs::OpenOptionsExt, path::Path}; use serde::Serialize; use windows::Win32::Foundation::{ ERROR_FILE_NOT_FOUND, ERROR_SUCCESS, FILETIME, MAX_PATH, WIN32_ERROR, }; +use windows::Win32::Storage::FileSystem::{DELETE, FILE_FLAG_OPEN_REPARSE_POINT}; use windows::Win32::System::Com::{ CLSCTX_INPROC_SERVER, COINIT_MULTITHREADED, CoCreateInstance, CoInitializeEx, IPersistFile, STGM_READ, @@ -508,6 +509,20 @@ fn remove_file(folder: &Path, name: &str, recycle: bool) -> Result<(), ActionErr if !path.is_file() { return Err(ActionError::NotFound); } + // Check the caller's delete access on the directory entry itself before + // handing it to the Shell. Release the handle before the recycle operation. + if let Err(error) = std::fs::File::options() + .access_mode(DELETE.0) + .custom_flags(FILE_FLAG_OPEN_REPARSE_POINT.0) + .open(&path) + { + crate::diagnostics::file_failure("startup open for deletion", &path, &error); + return Err(match error.kind() { + ErrorKind::PermissionDenied => ActionError::AccessDenied, + ErrorKind::NotFound => ActionError::NotFound, + _ => ActionError::Os(error.to_string()), + }); + } // The paths, each ended by a NUL, and the list by another. let mut from = wide(&path.to_string_lossy()); from.push(0); @@ -727,10 +742,11 @@ mod tests { .expect("icacls"); assert!(status.success()); } - assert!(matches!( - remove_file(&folder.0, "Locked.lnk", true), - Err(ActionError::AccessDenied) - )); + let result = remove_file(&folder.0, "Locked.lnk", true); + assert!( + matches!(result, Err(ActionError::AccessDenied)), + "{result:?}" + ); assert!(folder.0.join("Locked.lnk").exists()); }