fix: respect --force flag during index and partition creation
The index creation routine now uses the CLI `--force` argument instead of a hardcoded false value, enabling explicit overwrite control. Partition existence checks also verify for the designated subdirectory rather than the root path, ensuring conflict detection and cleanup only trigger when an actual partition layout exists.
This commit is contained in:
@@ -225,7 +225,7 @@ pub fn run(args: IndexArgs) {
|
|||||||
}
|
}
|
||||||
info
|
info
|
||||||
});
|
});
|
||||||
KmerIndex::create(&output, config, genome_info, false).unwrap_or_else(|e| {
|
KmerIndex::create(&output, config, genome_info, args.force).unwrap_or_else(|e| {
|
||||||
eprintln!("error creating index: {e}");
|
eprintln!("error creating index: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -59,7 +59,11 @@ impl KmerPartition {
|
|||||||
force: bool,
|
force: bool,
|
||||||
) -> SKResult<Self> {
|
) -> SKResult<Self> {
|
||||||
let root_path = path.as_ref().to_owned();
|
let root_path = path.as_ref().to_owned();
|
||||||
if root_path.exists() {
|
// `root_path` itself may already exist as a bare directory: callers
|
||||||
|
// typically hold an index-level lock file there before creating the
|
||||||
|
// partition layout. What actually signals a pre-existing partition
|
||||||
|
// set is the `PARTITIONS_SUBDIR` subdirectory, not the root itself.
|
||||||
|
if root_path.join(PARTITIONS_SUBDIR).exists() {
|
||||||
if force {
|
if force {
|
||||||
remove_dir_all(&root_path)?;
|
remove_dir_all(&root_path)?;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user