mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Read csv text in eagerly
This allows us to display a more useful "not utf-8" message, instead of a generic "invalid csv" message when the metadata can't be fetched.
This commit is contained in:
parent
ecaba5e655
commit
fe8cf5ae7d
1 changed files with 4 additions and 2 deletions
|
@ -5,11 +5,12 @@ use std::collections::HashMap;
|
|||
use std::collections::HashSet;
|
||||
use std::io::BufRead;
|
||||
use std::io::BufReader;
|
||||
use std::io::Cursor;
|
||||
use std::io::Read;
|
||||
use std::io::Seek;
|
||||
use std::io::SeekFrom;
|
||||
|
||||
use anki_io::open_file;
|
||||
use anki_io::read_to_string;
|
||||
pub use anki_proto::import_export::csv_metadata::Deck as CsvDeck;
|
||||
pub use anki_proto::import_export::csv_metadata::Delimiter;
|
||||
pub use anki_proto::import_export::csv_metadata::DupeResolution;
|
||||
|
@ -45,7 +46,8 @@ impl Collection {
|
|||
deck_id: Option<DeckId>,
|
||||
is_html: Option<bool>,
|
||||
) -> Result<CsvMetadata> {
|
||||
let mut reader = open_file(path)?;
|
||||
let text = read_to_string(path)?;
|
||||
let mut reader = Cursor::new(text);
|
||||
let meta =
|
||||
self.get_reader_metadata(&mut reader, delimiter, notetype_id, deck_id, is_html)?;
|
||||
if meta.preview.is_empty() {
|
||||
|
|
Loading…
Reference in a new issue