From e2b93744264254dc0767d6cb84871f6888c76da8 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Thu, 13 Aug 2026 19:35:40 +0200 Subject: [PATCH] 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. --- src/obikmer/src/cmd/index/mod.rs | 2 +- src/obikpartitionner/src/partition/kmer_partition.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/obikmer/src/cmd/index/mod.rs b/src/obikmer/src/cmd/index/mod.rs index e83f7910..ca9fe857 100644 --- a/src/obikmer/src/cmd/index/mod.rs +++ b/src/obikmer/src/cmd/index/mod.rs @@ -225,7 +225,7 @@ pub fn run(args: IndexArgs) { } 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}"); std::process::exit(1); }) diff --git a/src/obikpartitionner/src/partition/kmer_partition.rs b/src/obikpartitionner/src/partition/kmer_partition.rs index e24aad53..891e6f8a 100644 --- a/src/obikpartitionner/src/partition/kmer_partition.rs +++ b/src/obikpartitionner/src/partition/kmer_partition.rs @@ -59,7 +59,11 @@ impl KmerPartition { force: bool, ) -> SKResult { 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 { remove_dir_all(&root_path)?; } else {