rename directory entries

This commit is contained in:
2025-07-16 06:23:24 +02:00
parent b121c27b37
commit a2cb58867c
16 changed files with 389 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
use std::time::UNIX_EPOCH;
use anyhow::{Context, anyhow};
use anyhow::{Context, anyhow, bail};
use tokio::{fs, io::AsyncWriteExt as _};
use crate::domain::warren::{
@@ -156,6 +156,10 @@ impl FileSystem {
FilePath::new(&c)?
};
if fs::try_exists(&new_path).await? {
bail!("File already exists");
}
fs::rename(current_path, &new_path).await?;
Ok(new_path)

View File

@@ -70,6 +70,13 @@ impl WarrenMetrics for MetricsDebugLogger {
async fn record_warren_file_deletion_failure(&self) {
log::debug!("[Metrics] Warren file deletion failed");
}
async fn record_warren_entry_rename_success(&self) {
log::debug!("[Metrics] Warren entry rename succeeded");
}
async fn record_warren_entry_rename_failure(&self) {
log::debug!("[Metrics] Warren entry rename failed");
}
}
impl FileSystemMetrics for MetricsDebugLogger {

View File

@@ -71,6 +71,20 @@ impl WarrenNotifier for NotifierDebugLogger {
warren.name(),
);
}
async fn warren_entry_renamed(
&self,
warren: &Warren,
old_path: &crate::domain::warren::models::file::AbsoluteFilePath,
new_path: &FilePath,
) {
log::debug!(
"[Notifier] Renamed file {} to {} in warren {}",
old_path,
new_path,
warren.name(),
);
}
}
impl FileSystemNotifier for NotifierDebugLogger {