fix: resolve 7 critical security vulnerabilities from audit

This commit is contained in:
NimBold
2026-06-24 23:36:21 +03:30
parent 1a687d0081
commit b147ec5f78
8 changed files with 110 additions and 92 deletions
+16 -2
View File
@@ -240,8 +240,6 @@ impl<R: tauri::Runtime> QueueManager<R> {
true
}
/// Release the permit parked under `id`, if any. Idempotent. Wakes the
/// dispatcher so a freed slot is claimed promptly.
pub async fn release_permit(&self, id: &str) {
let removed = self.active_permits.lock().await.remove(id).is_some();
self.active_kinds.lock().await.remove(id);
@@ -250,6 +248,22 @@ impl<R: tauri::Runtime> QueueManager<R> {
}
}
/// Clear all permits belonging to aria2. Useful when aria2 WS connection drops.
pub async fn clear_aria2_permits(&self) {
let ids_to_fail: Vec<String> = {
let kinds = self.active_kinds.lock().await;
kinds
.iter()
.filter(|(_, kind)| matches!(kind, TaskKind::Aria2))
.map(|(id, _)| id.clone())
.collect()
};
for id in ids_to_fail {
self.apply_completion(&id, PendingOutcome::Error("Aria2 WebSocket connection lost".to_string())).await;
}
}
/// Number of un-acquired permits currently in the semaphore pool.
pub fn available_permits(&self) -> usize {
self.semaphore.available_permits()