Skip to content

Commit 6e3ace9

Browse files
committed
Fix PAF corruption: flush after each pairwise alignment write
Without flushing after each write_all(), buffered writes could be incomplete or corrupted if the process was interrupted or the buffer wasn't full. Now we flush after each pairwise alignment completes to ensure data integrity.
1 parent 7da17ca commit 6e3ace9

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,7 @@ fn align_multiple_fastas(
12171217
// Append to merged output
12181218
let paf_content = std::fs::read_to_string(temp_paf.path())?;
12191219
merged_output.write_all(paf_content.as_bytes())?;
1220+
merged_output.flush()?; // Flush after each alignment to prevent corruption
12201221

12211222
let alignment_count = paf_content.lines().count();
12221223
total_alignments += alignment_count;
@@ -1237,13 +1238,15 @@ fn align_multiple_fastas(
12371238

12381239
let paf_content = std::fs::read_to_string(temp_paf.path())?;
12391240
merged_output.write_all(paf_content.as_bytes())?;
1241+
merged_output.flush()?; // Flush after each alignment to prevent corruption
12401242

12411243
let alignment_count = paf_content.lines().count();
12421244
total_alignments += alignment_count;
12431245
total_pairs += 1;
12441246
}
12451247
}
12461248

1249+
// Final flush (redundant but safe)
12471250
merged_output.flush()?;
12481251

12491252
if !quiet {

0 commit comments

Comments
 (0)