mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
Fix signature of import_apkg()
This commit is contained in:
parent
468c0286f9
commit
d6134748f2
1 changed files with 7 additions and 15 deletions
|
@ -6,6 +6,7 @@ use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
fs::File,
|
fs::File,
|
||||||
io, mem,
|
io, mem,
|
||||||
|
path::Path,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ use crate::{
|
||||||
MediaManager,
|
MediaManager,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
search::SearchNode,
|
||||||
text::replace_media_refs,
|
text::replace_media_refs,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,16 +89,10 @@ impl SafeMediaEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Collection {
|
impl Collection {
|
||||||
pub fn import_apkg(
|
pub fn import_apkg(&mut self, path: impl AsRef<Path>) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
path: &str,
|
|
||||||
search: impl TryIntoSearch,
|
|
||||||
with_scheduling: bool,
|
|
||||||
) -> Result<()> {
|
|
||||||
let file = File::open(path)?;
|
let file = File::open(path)?;
|
||||||
let archive = ZipArchive::new(file)?;
|
let archive = ZipArchive::new(file)?;
|
||||||
|
let mut ctx = Context::new(archive, self)?;
|
||||||
let mut ctx = Context::new(archive, self, search, with_scheduling)?;
|
|
||||||
ctx.import()?;
|
ctx.import()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -126,13 +122,9 @@ impl ExchangeData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Context<'a> {
|
impl<'a> Context<'a> {
|
||||||
fn new(
|
fn new(mut archive: ZipArchive<File>, target_col: &'a mut Collection) -> Result<Self> {
|
||||||
mut archive: ZipArchive<File>,
|
let data =
|
||||||
target_col: &'a mut Collection,
|
ExchangeData::gather_from_archive(&mut archive, SearchNode::WholeCollection, true)?;
|
||||||
search: impl TryIntoSearch,
|
|
||||||
with_scheduling: bool,
|
|
||||||
) -> Result<Self> {
|
|
||||||
let data = ExchangeData::gather_from_archive(&mut archive, search, with_scheduling)?;
|
|
||||||
let guid_map = target_col.storage.note_guid_map()?;
|
let guid_map = target_col.storage.note_guid_map()?;
|
||||||
let usn = target_col.usn()?;
|
let usn = target_col.usn()?;
|
||||||
let normalize_notes = target_col.get_config_bool(BoolKey::NormalizeNoteText);
|
let normalize_notes = target_col.get_config_bool(BoolKey::NormalizeNoteText);
|
||||||
|
|
Loading…
Reference in a new issue