Audit improvements: fix Windows atomic rename collisions and clean up compiler warnings

This commit is contained in:
RarDog
2026-08-27 15:55:06 +03:00
parent f65b15452f
commit c27ac0f41c
7 changed files with 20 additions and 0 deletions
+1
View File
@@ -11,6 +11,7 @@ use zip::{CompressionMethod, ZipArchive, ZipWriter};
// ─────────────────────────────────────────────────────────────────
/// Compress a whole folder into a ZIP archive with fast Deflate compression
#[allow(dead_code)]
pub fn compress_folder_to_zip(
src_dir: &Path,
zip_dest: &Path,
+4
View File
@@ -96,12 +96,14 @@ impl TransferClient {
}
}
#[allow(dead_code)]
pub async fn is_paused(&self, session_id: &str) -> bool {
let flags = self.pause_flags.lock().await;
flags.get(session_id).map(|f| f.load(Ordering::Relaxed)).unwrap_or(false)
}
/// Race-ping multiple candidate URLs and return the fastest responding one
#[allow(dead_code)]
pub async fn pick_fastest_url(&self, candidates: &[String]) -> Option<String> {
if candidates.is_empty() { return None; }
if candidates.len() == 1 { return Some(candidates[0].clone()); }
@@ -1040,6 +1042,7 @@ impl TransferClient {
}
/// Fetch active watch-party state from host peer
#[allow(dead_code)]
pub async fn get_watch_party(
&self,
peer_url: &str,
@@ -1062,6 +1065,7 @@ impl TransferClient {
}
/// Send watch-party sync event to host peer
#[allow(dead_code)]
pub async fn send_watch_party_event(
&self,
peer_url: &str,
+2
View File
@@ -10,6 +10,7 @@ use tracing::info;
#[derive(Debug, Clone)]
pub struct SyncStatusUpdate {
#[allow(dead_code)]
pub pair_id: String,
pub message: String,
pub is_error: bool,
@@ -78,6 +79,7 @@ impl FolderSyncEngine {
}
}
#[allow(dead_code)]
pub fn pairs_handle(&self) -> Arc<RwLock<Vec<FolderSyncPairConfig>>> {
self.pairs.clone()
}
+3
View File
@@ -694,6 +694,9 @@ async fn handle_finish_transfer(
let part_path = state.download_dir.join(format!("{}.zerosend_part", safe_rel_path.to_string_lossy()));
if part_path.exists() {
if target_path.exists() {
let _ = tokio::fs::remove_file(&target_path).await;
}
let _ = tokio::fs::rename(&part_path, &target_path).await;
if let Some(expected_hash) = &f.sha256 {
if let Ok(actual_hash) = super::client::compute_file_sha256(&target_path) {
+3
View File
@@ -14,6 +14,7 @@ use tracing::{info, warn};
pub struct WebDavState {
pub shared_folders: Arc<RwLock<Vec<SharedFolderConfig>>>,
#[allow(dead_code)]
pub port: u16,
}
@@ -389,6 +390,7 @@ mod urlencoding {
}
/// Helper function to mount Windows Network Drive via `net use`
#[allow(dead_code)]
pub fn mount_webdav_drive(drive_letter: char, port: u16) -> Result<String, String> {
let drive = format!("{}:", drive_letter);
let url = format!("http://127.0.0.1:{}/webdav", port);
@@ -412,6 +414,7 @@ pub fn mount_webdav_drive(drive_letter: char, port: u16) -> Result<String, Strin
}
/// Helper function to unmount Windows Network Drive
#[allow(dead_code)]
pub fn unmount_webdav_drive(drive_letter: char) -> Result<(), String> {
let drive = format!("{}:", drive_letter);
let output = std::process::Command::new("net")
+6
View File
@@ -49,6 +49,7 @@ pub struct AudioTrackInfo {
pub name: String,
pub url: String,
pub peer_name: String,
#[allow(dead_code)]
pub is_playing: bool,
}
@@ -212,6 +213,7 @@ pub struct ZeroSendApp {
// Media & Audio & Watch Party
pub active_audio: Option<AudioTrackInfo>,
#[allow(dead_code)]
pub audio_volume: f32,
pub watch_party_session: Option<crate::transfer::WatchPartySyncEvent>,
pub is_in_watch_party: bool,
@@ -232,8 +234,11 @@ pub struct ZeroSendApp {
pub new_sync_folder_id: String,
// WebDAV Windows Drive Mount State
#[allow(dead_code)]
pub webdav_mounted: bool,
#[allow(dead_code)]
pub webdav_drive_letter: char,
#[allow(dead_code)]
pub webdav_status_msg: Option<String>,
// Gitea Updater State
@@ -255,6 +260,7 @@ pub struct ZeroSendApp {
share_text_rx: mpsc::UnboundedReceiver<(String, String, String, String, Option<String>, Option<String>, Option<String>, bool)>,
share_text_tx: mpsc::UnboundedSender<(String, String, String, String, Option<String>, Option<String>, Option<String>, bool)>,
sync_status_rx: mpsc::UnboundedReceiver<crate::transfer::SyncStatusUpdate>,
#[allow(dead_code)]
sync_status_tx: mpsc::UnboundedSender<crate::transfer::SyncStatusUpdate>,
update_rx: mpsc::UnboundedReceiver<Result<UpdateInfo, String>>,
update_tx: mpsc::UnboundedSender<Result<UpdateInfo, String>>,
+1
View File
@@ -57,6 +57,7 @@ impl Default for VimViewerModal {
}
impl VimViewerModal {
#[allow(dead_code)]
pub fn open(
&mut self,
file_name: String,