mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-28 16:30:52 +08:00
fix(tests): suppress clippy expect warnings in enhance function
fix(timer): improve task removal logic in add_task method refactor(notification): drop binding after emitting event chore(Cargo): add lints section to Cargo.toml
This commit is contained in:
@@ -123,3 +123,6 @@ tauri-plugin-updater = "2.9.0"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = { workspace = true }
|
criterion = { workspace = true }
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
@@ -4,7 +4,7 @@ use super::CmdResult;
|
|||||||
use crate::core::{CoreManager, handle, manager::RunningMode};
|
use crate::core::{CoreManager, handle, manager::RunningMode};
|
||||||
use clash_verge_logging::{Type, logging};
|
use clash_verge_logging::{Type, logging};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use tauri::Manager;
|
use tauri::Manager as _;
|
||||||
use tauri_plugin_clash_verge_sysinfo::Platform;
|
use tauri_plugin_clash_verge_sysinfo::Platform;
|
||||||
use tauri_plugin_clipboard_manager::ClipboardExt as _;
|
use tauri_plugin_clipboard_manager::ClipboardExt as _;
|
||||||
|
|
||||||
|
|||||||
@@ -102,8 +102,6 @@ impl NotificationSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clippy 似乎对 parking lot 的 RwLock 有误报,这里禁用相关警告
|
|
||||||
#[allow(clippy::significant_drop_tightening)]
|
|
||||||
fn process_event(handle: &super::handle::Handle, event: FrontendEvent) {
|
fn process_event(handle: &super::handle::Handle, event: FrontendEvent) {
|
||||||
let binding = handle.notification_system.read();
|
let binding = handle.notification_system.read();
|
||||||
let system = match binding.as_ref() {
|
let system = match binding.as_ref() {
|
||||||
@@ -117,6 +115,7 @@ impl NotificationSystem {
|
|||||||
|
|
||||||
if let Some(window) = super::handle::Handle::get_window() {
|
if let Some(window) = super::handle::Handle::get_window() {
|
||||||
system.emit_to_window(&window, event);
|
system.emit_to_window(&window, event);
|
||||||
|
drop(binding);
|
||||||
thread::sleep(timing::EVENT_EMIT_DELAY);
|
thread::sleep(timing::EVENT_EMIT_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,12 +253,11 @@ impl Timer {
|
|||||||
|
|
||||||
// Now perform async operations without holding locks
|
// Now perform async operations without holding locks
|
||||||
let delay_timer = self.delay_timer.write();
|
let delay_timer = self.delay_timer.write();
|
||||||
let mut timer_map = self.timer_map.write();
|
|
||||||
for (uid, tid, interval) in operations_to_add {
|
for (uid, tid, interval) in operations_to_add {
|
||||||
if let Err(e) = self.add_task(&delay_timer, uid.clone(), tid, interval) {
|
if let Err(e) = self.add_task(&delay_timer, uid.clone(), tid, interval) {
|
||||||
logging_error!(Type::Timer, "Failed to add task for uid {}: {}", uid, e);
|
logging_error!(Type::Timer, "Failed to add task for uid {}: {}", uid, e);
|
||||||
// Rollback on failure - remove from timer_map
|
// Rollback on failure - remove from timer_map
|
||||||
timer_map.remove(&uid);
|
self.timer_map.write().remove(&uid);
|
||||||
} else {
|
} else {
|
||||||
logging!(debug, Type::Timer, "Added task {} for uid {}", tid, uid);
|
logging!(debug, Type::Timer, "Added task {} for uid {}", tid, uid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -692,6 +692,7 @@ pub async fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
|
|||||||
(config, exists_keys, result_map)
|
(config, exists_keys, result_map)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::expect_used)]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::cleanup_proxy_groups;
|
use super::cleanup_proxy_groups;
|
||||||
|
|||||||
Reference in New Issue
Block a user