fix(core): fix problematic handling of target directory in migration

This commit is contained in:
Federico Terzi 2021-09-09 19:45:50 +02:00
parent b5422b939d
commit 27f53c386c

View File

@ -135,12 +135,18 @@ fn migrate_main(args: CliModuleArgs) -> i32 {
fs_extra::dir::get_dir_content(&paths.config).expect("unable to list legacy dir files");
to_be_removed.extend(legacy_dir_content.files);
to_be_removed.extend(legacy_dir_content.directories);
// Skip the config directory itself to preserve the symbolic link (if present)
let config_dir_as_str = paths.config.to_string_lossy().to_string();
to_be_removed.retain(|path| path != &config_dir_as_str);
fs_extra::remove_items(&to_be_removed).expect("unable to remove previous configuration");
fs_extra::dir::copy(
&temp_out_dir,
&paths.config,
&CopyOptions {
copy_inside: true,
content_only: true,
..Default::default()
},
)