Server: Allows loading multiple files in //

pull/186/head
Tpt 3 years ago
parent 15072f21b5
commit bb0d4fb2c4
  1. 13
      server/src/main.rs

@ -24,6 +24,7 @@ use std::fs::File;
use std::io::{BufReader, Error, ErrorKind, Read, Write};
use std::rc::Rc;
use std::str::FromStr;
use std::thread::{spawn, JoinHandle};
use std::time::Duration;
use url::form_urlencoded;
@ -64,6 +65,7 @@ pub fn main() -> std::io::Result<()> {
.long("file")
.help("The file to load")
.takes_value(true)
.multiple(true)
.required(true),
),
)
@ -77,7 +79,10 @@ pub fn main() -> std::io::Result<()> {
match matches.subcommand() {
("load", Some(submatches)) => {
let file = submatches.value_of("file").unwrap();
let handles = submatches.values_of("file").unwrap().into_iter().map(|file| {
let store = store.clone();
let file = file.to_string();
spawn(move || {
let format = file
.rsplit_once(".")
.and_then(|(_, extension)| {
@ -91,6 +96,12 @@ pub fn main() -> std::io::Result<()> {
)
})?;
store.bulk_load_dataset(BufReader::new(File::open(file)?), format, None)?;
Ok(())
})
}).collect::<Vec<JoinHandle<Result<(),Error>>>>();
for handle in handles {
handle.join().unwrap()?;
}
store.optimize()
}
("serve", Some(submatches)) => {

Loading…
Cancel
Save