Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple small VCF auto-indexing bugs. #1581

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ int sam_idx_save(htsFile *fp) {
errno = -ret;
return -1;
}
if (bgzf_flush(fp->fp.bgzf) < 0)
if (!fp->is_bgzf || bgzf_flush(fp->fp.bgzf) < 0)
return -1;
hts_idx_amend_last(fp->idx, bgzf_tell(fp->fp.bgzf));

Expand Down
2 changes: 2 additions & 0 deletions vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3570,6 +3570,8 @@ int vcf_write(htsFile *fp, const bcf_hdr_t *h, bcf1_t *v)
if ( fp->format.compression!=no_compression ) {
if (bgzf_flush_try(fp->fp.bgzf, fp->line.l) < 0)
return -1;
if (fp->idx)
hts_idx_amend_last(fp->idx, bgzf_tell(fp->fp.bgzf));
ret = bgzf_write(fp->fp.bgzf, fp->line.s, fp->line.l);
} else {
ret = hwrite(fp->fp.hfile, fp->line.s, fp->line.l);
Expand Down