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