rename directory entries
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user