Add legacy arg to ExportAnkiPackage

Currently not exposed on the frontend
This commit is contained in:
Damien Elmes 2022-04-26 21:30:47 +10:00
parent ede9698aea
commit 055b404165
5 changed files with 14 additions and 4 deletions

View file

@ -55,10 +55,11 @@ message ExportAnkiPackageRequest {
string out_path = 1;
bool with_scheduling = 2;
bool with_media = 3;
bool legacy = 4;
oneof selector {
generic.Empty whole_collection = 4;
int64 deck_id = 5;
notes.NoteIds note_ids = 6;
generic.Empty whole_collection = 5;
int64 deck_id = 6;
notes.NoteIds note_ids = 7;
}
}

View file

@ -389,6 +389,7 @@ class Collection(DeprecatedNamesMixin):
out_path=out_path,
with_scheduling=with_scheduling,
with_media=with_media,
legacy=True,
**selector_kwarg,
)
return self._backend.export_anki_package(request)

View file

@ -66,6 +66,7 @@ impl ImportExportService for Backend {
SearchNode::from_selector(selector),
input.with_scheduling,
input.with_media,
input.legacy,
None,
self.export_progress_fn(),
)

View file

@ -24,12 +24,14 @@ use crate::{
impl Collection {
/// Returns number of exported notes.
#[allow(clippy::too_many_arguments)]
pub fn export_apkg(
&mut self,
out_path: impl AsRef<Path>,
search: impl TryIntoSearch,
with_scheduling: bool,
with_media: bool,
legacy: bool,
media_fn: Option<Box<dyn FnOnce(HashSet<PathBuf>) -> MediaIter>>,
progress_fn: impl FnMut(usize) -> Result<()>,
) -> Result<usize> {
@ -54,7 +56,11 @@ impl Collection {
let col_size = temp_col.as_file().metadata()?.len() as usize;
export_collection(
Meta::new_legacy(),
if legacy {
Meta::new_legacy()
} else {
Meta::new()
},
temp_apkg.path(),
&mut temp_col,
col_size,

View file

@ -35,6 +35,7 @@ fn roundtrip() {
SearchNode::from_deck_name("parent::sample"),
true,
true,
true,
None,
|_| Ok(()),
)