refactor: clean up unused code and improve conditionals in various modules

This commit is contained in:
GW_MC
2026-07-18 04:59:42 +00:00
parent 83037f3ee2
commit 076e87695d
11 changed files with 35 additions and 81 deletions

View File

@@ -2,7 +2,7 @@ use std::sync::Arc;
use fs4::tokio::AsyncFileExt;
use thiserror::Error;
use tokio::{io::AsyncWriteExt, process::Command};
use tokio::io::AsyncWriteExt;
use tracing::warn;
use crate::{config::settings::NginxSettings, service::master_handler::MasterHandlerError};
@@ -222,19 +222,19 @@ impl FsHandler for FsHandlerImpl {
let mut entries = tokio::fs::read_dir(&deployment_dir).await?;
let mut candidates: Vec<(std::path::PathBuf, std::time::SystemTime)> = Vec::new();
while let Some(entry) = entries.next_entry().await? {
if entry.file_type().await.map_or(false, |t| t.is_dir()) {
if let Ok(mtime) = entry.metadata().await.and_then(|m| m.modified()) {
candidates.push((entry.path(), mtime));
}
if entry.file_type().await.is_ok_and(|t| t.is_dir())
&& let Ok(mtime) = entry.metadata().await.and_then(|m| m.modified())
{
candidates.push((entry.path(), mtime));
}
}
// sort descending by mtime (newest first)
candidates.sort_by(|a, b| b.1.cmp(&a.1));
candidates.sort_by_key(|b| std::cmp::Reverse(b.1));
for (dir, _) in &candidates {
let mut dir_entries = tokio::fs::read_dir(dir).await?;
while let Some(file) = dir_entries.next_entry().await? {
if file.file_type().await.map_or(false, |t| t.is_file()) {
if file.file_type().await.is_ok_and(|t| t.is_file()) {
let name = file.file_name().to_string_lossy().to_string();
if name == "nginx.conf" || name.ends_with(".conf") {
let path = file.path().to_string_lossy().to_string();