Skip to content
Merged
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
22 changes: 17 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use gen::exports::fasta::export_fasta;
use gen::exports::genbank::export_genbank;
use gen::exports::gfa::export_gfa;
use gen::fasta::FastaError;
use gen::genbank::GenBankError;
use gen::get_connection;
use gen::graph_operators::{derive_chunks, get_path, make_stitch};
use gen::imports::fasta::import_fasta;
Expand Down Expand Up @@ -608,11 +609,16 @@ fn main() {
}
}
} else if let Some(gb) = gb {
let f = File::open(gb).unwrap();
let _ = import_genbank(
let mut reader: Box<dyn std::io::Read> = if gb.ends_with(".gz") {
let file = File::open(gb.clone()).unwrap();
Box::new(flate2::read::GzDecoder::new(file))
} else {
Box::new(File::open(gb.clone()).unwrap())
};
match import_genbank(
&conn,
&operation_conn,
&f,
&mut reader,
name.deref(),
sample.as_deref(),
OperationInfo {
Expand All @@ -622,8 +628,14 @@ fn main() {
}],
description: "GenBank Import".to_string(),
},
);
println!("Genbank imported.");
) {
Ok(_) => println!("GenBank Imported."),
Err(err) => {
conn.execute("ROLLBACK TRANSACTION;", []).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I have a to-do to make sure all commands roll back on errors, eventually

operation_conn.execute("ROLLBACK TRANSACTION;", []).unwrap();
panic!("Import failed: {err:?}");
}
}
} else if region_name.is_some() && parts.is_some() && library.is_some() {
import_library(
&conn,
Expand Down