Skip to content

Commit

Permalink
Add check for existing destination file before migration (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
JegernOUTT authored Dec 16, 2024
1 parent bf60155 commit 9f4c9f1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/global_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ pub async fn migrate_to_config_folder(
let is_yaml_cfg = file_type.is_file() && path.extension().and_then(|e| e.to_str()) == Some("yaml");
if is_yaml_cfg {
let new_path = config_dir.join(&file_name);
if new_path.exists() {
tracing::info!("cannot migrate {:?} to {:?}: destination exists".to_string(), path, new_path);
continue;
}
tokio::fs::rename(&path, &new_path).await?;
tracing::info!("migrated {:?} to {:?}", path, new_path);
}
Expand Down

0 comments on commit 9f4c9f1

Please sign in to comment.