Fix code quality: trailing whitespace, unused imports, clippy warnings

- Fix trailing whitespace in kex.rs and s3.rs
- Add missing KexProposal import in kex_complete.rs
- Auto-fix clippy warnings across all crates
- All 153 tests pass
This commit is contained in:
Warren
2026-06-19 05:21:38 +08:00
parent 4b37e524cf
commit d94cb2df4c
135 changed files with 7256 additions and 4321 deletions

View File

@@ -21,56 +21,56 @@ pub fn handle_archive_command(cmd: ArchiveCommand) -> anyhow::Result<()> {
match cmd {
ArchiveCommand::Decompress { file, output } => {
use crate::archive::{ArchiveConfig, ProcessorRegistry};
println!("Decompressing {} to {}", file, output);
let archive_path = Path::new(&file);
if !archive_path.exists() {
return Err(anyhow::anyhow!("Archive file not found: {}", file));
}
let config = ArchiveConfig::default();
let mut registry = ProcessorRegistry::new(config);
registry.initialize()?;
let output_path = Path::new(&output);
std::fs::create_dir_all(output_path)?;
let processor = registry.get_processor_mut(archive_path)?;
let result = processor.extract_all(output_path)?;
println!("✓ Archive decompressed to: {}", output);
println!("✓ Files extracted: {}", result.success_files);
println!("✓ Total size: {} bytes", result.total_bytes);
}
ArchiveCommand::List { file } => {
use crate::archive::{ArchiveConfig, ProcessorRegistry};
println!("Listing contents of {}", file);
let archive_path = Path::new(&file);
if !archive_path.exists() {
return Err(anyhow::anyhow!("Archive file not found: {}", file));
}
let config = ArchiveConfig::default();
let mut registry = ProcessorRegistry::new(config);
registry.initialize()?;
let processor = registry.get_processor_mut(archive_path)?;
let metadata = processor.open(archive_path)?;
let entries = processor.list_entries()?;
println!("=== Archive Contents ===");
println!("Format: {}", metadata.format);
println!("Total files: {}", metadata.total_files);
println!("Total size: {} bytes", metadata.total_size);
println!("");
println!();
for entry in entries {
println!(" {} ({} bytes)", entry.path.display(), entry.size);
}
}
}
Ok(())
}
}

View File

@@ -17,4 +17,4 @@ pub fn handle_hash_command(cmd: HashCommand) -> anyhow::Result<()> {
}
}
Ok(())
}
}

View File

@@ -1,8 +1,8 @@
pub mod scan;
pub mod hash;
pub mod archive;
pub mod sync;
pub mod hash;
pub mod mount;
pub mod scan;
pub mod sync;
use clap::Subcommand;
@@ -29,4 +29,4 @@ pub async fn handle_storage_command(cmd: StorageCommands) -> anyhow::Result<()>
StorageCommands::Mount(c) => mount::handle_mount_command(c)?,
}
Ok(())
}
}

View File

@@ -22,21 +22,25 @@ pub enum MountCommand {
pub fn handle_mount_command(cmd: MountCommand) -> anyhow::Result<()> {
match cmd {
MountCommand::Attach { type_, server, path } => {
MountCommand::Attach {
type_,
server,
path,
} => {
use std::process::Command;
println!("Mounting {} from {} to {}", type_, server, path);
if type_ == "nfs" {
let mount_point = std::path::Path::new(&path);
std::fs::create_dir_all(mount_point)?;
let nfs_path = format!("{}:{}", server, path);
let status = Command::new("mount")
.args(["-t", "nfs", &nfs_path, &path])
.status()?;
if status.success() {
println!("✓ NFS mounted: {} to {}", nfs_path, path);
} else {
@@ -45,31 +49,32 @@ pub fn handle_mount_command(cmd: MountCommand) -> anyhow::Result<()> {
} else if type_ == "smb" {
let mount_point = std::path::Path::new(&path);
std::fs::create_dir_all(mount_point)?;
let smb_path = format!("//{}", server);
let status = Command::new("mount")
.args(["-t", "smbfs", &smb_path, &path])
.status()?;
if status.success() {
println!("✓ SMB mounted: {} to {}", smb_path, path);
} else {
return Err(anyhow::anyhow!("SMB mount failed"));
}
} else {
return Err(anyhow::anyhow!("Unknown mount type: {}. Use 'nfs' or 'smb'", type_));
return Err(anyhow::anyhow!(
"Unknown mount type: {}. Use 'nfs' or 'smb'",
type_
));
}
}
MountCommand::Detach { path } => {
use std::process::Command;
println!("Unmounting {}", path);
let status = Command::new("umount")
.arg(&path)
.status()?;
let status = Command::new("umount").arg(&path).status()?;
if status.success() {
println!("✓ Unmounted: {}", path);
} else {
@@ -78,14 +83,13 @@ pub fn handle_mount_command(cmd: MountCommand) -> anyhow::Result<()> {
}
MountCommand::List => {
use std::process::Command;
println!("Listing mounted storage");
let output = Command::new("mount")
.output()?;
let output = Command::new("mount").output()?;
let mounts = String::from_utf8_lossy(&output.stdout);
println!("=== Mounted Filesystems ===");
for line in mounts.lines() {
if line.contains("nfs") || line.contains("smbfs") || line.contains("fuse") {
@@ -95,4 +99,4 @@ pub fn handle_mount_command(cmd: MountCommand) -> anyhow::Result<()> {
}
}
Ok(())
}
}

View File

@@ -31,4 +31,4 @@ pub fn handle_scan_command(cmd: ScanCommand) -> anyhow::Result<()> {
}
}
Ok(())
}
}

View File

@@ -17,27 +17,31 @@ pub enum SyncCommand {
pub fn handle_sync_command(cmd: SyncCommand) -> anyhow::Result<()> {
match cmd {
SyncCommand::Start { source, target, mode } => {
SyncCommand::Start {
source,
target,
mode,
} => {
use std::path::Path;
println!("Syncing {} to {} (mode: {})", source, target, mode);
let source_path = Path::new(&source);
let target_path = Path::new(&target);
if !source_path.exists() {
return Err(anyhow::anyhow!("Source path not found: {}", source));
}
if mode == "mirror" {
std::fs::create_dir_all(target_path)?;
let entries = std::fs::read_dir(source_path)?;
for entry in entries {
let entry = entry?;
let path = entry.path();
let target_file = target_path.join(entry.file_name());
if path.is_file() {
std::fs::copy(&path, &target_file)?;
println!(" Copied: {:?}", entry.file_name());
@@ -46,7 +50,7 @@ pub fn handle_sync_command(cmd: SyncCommand) -> anyhow::Result<()> {
println!(" Created directory: {:?}", entry.file_name());
}
}
println!("✓ Sync completed (mirror mode)");
} else {
return Err(anyhow::anyhow!("Unknown sync mode: {}. Use 'mirror'", mode));
@@ -59,4 +63,4 @@ pub fn handle_sync_command(cmd: SyncCommand) -> anyhow::Result<()> {
}
}
Ok(())
}
}