mirror of
https://github.com/NexVeridian/wikidata-to-surrealdb.git
synced 2025-09-02 09:59:13 +00:00
fix: async for init_reader
This commit is contained in:
parent
5fa50cf69f
commit
47cde83c7a
4 changed files with 13 additions and 7 deletions
|
@ -46,7 +46,9 @@ async fn main() -> Result<(), Error> {
|
|||
sleep(Duration::from_secs(10)).await;
|
||||
let pb = init_progress_bar::create_pb().await;
|
||||
let reader = File_Format::new(get_wikidata_file_format().await)
|
||||
.reader(get_wikidata_file_name().await)?;
|
||||
.await
|
||||
.reader(get_wikidata_file_name().await)
|
||||
.await?;
|
||||
|
||||
fs::create_dir_all("data/temp").await?;
|
||||
fs::remove_dir_all("data/temp").await?;
|
||||
|
|
|
@ -11,14 +11,14 @@ pub enum File_Format {
|
|||
bz2,
|
||||
}
|
||||
impl File_Format {
|
||||
pub fn new(file: &str) -> Self {
|
||||
pub async fn new(file: &str) -> Self {
|
||||
match file {
|
||||
"json" => Self::json,
|
||||
"bz2" => Self::bz2,
|
||||
_ => panic!("Unknown file format"),
|
||||
}
|
||||
}
|
||||
pub fn reader(self, file: &str) -> Result<Box<dyn BufRead>, Error> {
|
||||
pub async fn reader(self, file: &str) -> Result<Box<dyn BufRead>, Error> {
|
||||
let file = File::open(file)?;
|
||||
match self {
|
||||
File_Format::json => Ok(Box::new(BufReader::new(file))),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue