ImportProgress::Collection → ImportProgress::File

This commit is contained in:
RumovZ 2022-04-29 10:39:56 +02:00
parent 76f4bf26ea
commit c65d1818ed
5 changed files with 8 additions and 7 deletions

View file

@ -78,6 +78,7 @@ importing-processed-media-file =
*[other] Imported { $count } media files *[other] Imported { $count } media files
} }
importing-importing-collection = Importing collection... importing-importing-collection = Importing collection...
importing-importing-file = Importing file...
importing-failed-to-import-media-file = Failed to import media file: { $debugInfo } importing-failed-to-import-media-file = Failed to import media file: { $debugInfo }
importing-processed-notes = importing-processed-notes =
{ $count -> { $count ->

View file

@ -108,7 +108,7 @@ pub(super) fn progress_to_proto(progress: Option<Progress>, tr: &I18n) -> pb::Pr
} }
Progress::Import(progress) => pb::progress::Value::Importing( Progress::Import(progress) => pb::progress::Value::Importing(
match progress { match progress {
ImportProgress::Collection => tr.importing_importing_collection(), ImportProgress::File => tr.importing_importing_file(),
ImportProgress::Media(n) => tr.importing_processed_media_file(n), ImportProgress::Media(n) => tr.importing_processed_media_file(n),
ImportProgress::MediaCheck(n) => tr.media_check_checked(n), ImportProgress::MediaCheck(n) => tr.media_check_checked(n),
ImportProgress::Notes(n) => tr.importing_processed_notes(n), ImportProgress::Notes(n) => tr.importing_processed_notes(n),

View file

@ -9,7 +9,7 @@ use crate::prelude::*;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub enum ImportProgress { pub enum ImportProgress {
Collection, File,
Media(usize), Media(usize),
MediaCheck(usize), MediaCheck(usize),
Notes(usize), Notes(usize),

View file

@ -42,7 +42,7 @@ impl Collection {
path: impl AsRef<Path>, path: impl AsRef<Path>,
progress_fn: &mut ProgressFn, progress_fn: &mut ProgressFn,
) -> Result<OpOutput<NoteLog>> { ) -> Result<OpOutput<NoteLog>> {
progress_fn(ImportProgress::Collection)?; progress_fn(ImportProgress::File)?;
let file = File::open(path)?; let file = File::open(path)?;
let archive = ZipArchive::new(file)?; let archive = ZipArchive::new(file)?;
@ -79,7 +79,7 @@ impl<'a> Context<'a> {
fn import(&mut self) -> Result<NoteLog> { fn import(&mut self) -> Result<NoteLog> {
let mut media_map = self.prepare_media()?; let mut media_map = self.prepare_media()?;
(self.progress_fn)(ImportProgress::Collection)?; (self.progress_fn)(ImportProgress::File)?;
let note_imports = self.import_notes_and_notetypes(&mut media_map)?; let note_imports = self.import_notes_and_notetypes(&mut media_map)?;
let imported_decks = self.import_decks_and_configs()?; let imported_decks = self.import_decks_and_configs()?;
self.import_cards_and_revlog(&note_imports.id_map, &imported_decks)?; self.import_cards_and_revlog(&note_imports.id_map, &imported_decks)?;

View file

@ -33,7 +33,7 @@ pub fn import_colpkg(
mut progress_fn: impl FnMut(ImportProgress) -> Result<()>, mut progress_fn: impl FnMut(ImportProgress) -> Result<()>,
log: &Logger, log: &Logger,
) -> Result<()> { ) -> Result<()> {
progress_fn(ImportProgress::Collection)?; progress_fn(ImportProgress::File)?;
let col_path = PathBuf::from(target_col_path); let col_path = PathBuf::from(target_col_path);
let mut tempfile = tempfile_in_parent_of(&col_path)?; let mut tempfile = tempfile_in_parent_of(&col_path)?;
@ -42,9 +42,9 @@ pub fn import_colpkg(
let meta = Meta::from_archive(&mut archive)?; let meta = Meta::from_archive(&mut archive)?;
copy_collection(&mut archive, &mut tempfile, &meta)?; copy_collection(&mut archive, &mut tempfile, &meta)?;
progress_fn(ImportProgress::Collection)?; progress_fn(ImportProgress::File)?;
check_collection_and_mod_schema(tempfile.path())?; check_collection_and_mod_schema(tempfile.path())?;
progress_fn(ImportProgress::Collection)?; progress_fn(ImportProgress::File)?;
restore_media( restore_media(
&meta, &meta,