mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Improve import messaging when notetype has changed (#2483)
* Fix file extension not being appended on export Regressed in #2427 * Improve import messaging when notetype has changed - If the local notes are up to date, we don't need to warn about the changed notetype, as no updates are required. - Make it clearer that a changed notetype only affects updates. Will update the docs as well.
This commit is contained in:
parent
57d6e99262
commit
894b7862e3
5 changed files with 24 additions and 25 deletions
|
@ -34,8 +34,8 @@ importing-mnemosyne-20-deck-db = Mnemosyne 2.0 Deck (*.db)
|
||||||
importing-multicharacter-separators-are-not-supported-please = Multi-character separators are not supported. Please enter one character only.
|
importing-multicharacter-separators-are-not-supported-please = Multi-character separators are not supported. Please enter one character only.
|
||||||
importing-notes-added-from-file = Notes added from file: { $val }
|
importing-notes-added-from-file = Notes added from file: { $val }
|
||||||
importing-notes-found-in-file = Notes found in file: { $val }
|
importing-notes-found-in-file = Notes found in file: { $val }
|
||||||
importing-notes-skipped-as-theyre-already-in = Notes skipped, as they're already in your collection: { $val }
|
importing-notes-skipped-as-theyre-already-in = Notes skipped, as up-to-date copies are already in your collection: { $val }
|
||||||
importing-notes-that-could-not-be-imported = Notes that could not be imported as note type has changed: { $val }
|
importing-notes-skipped-update-due-to-notetype = Notes not updated, as notetype has been modified since you first imported the notes: { $val }
|
||||||
importing-notes-updated-as-file-had-newer = Notes updated, as file had newer version: { $val }
|
importing-notes-updated-as-file-had-newer = Notes updated, as file had newer version: { $val }
|
||||||
importing-packaged-anki-deckcollection-apkg-colpkg-zip = Packaged Anki Deck/Collection (*.apkg *.colpkg *.zip)
|
importing-packaged-anki-deckcollection-apkg-colpkg-zip = Packaged Anki Deck/Collection (*.apkg *.colpkg *.zip)
|
||||||
importing-pauker-18-lesson-paugz = Pauker 1.8 Lesson (*.pau.gz)
|
importing-pauker-18-lesson-paugz = Pauker 1.8 Lesson (*.pau.gz)
|
||||||
|
@ -120,3 +120,4 @@ importing-cards-added =
|
||||||
|
|
||||||
importing-importing-collection = Importing collection...
|
importing-importing-collection = Importing collection...
|
||||||
importing-unable-to-import-filename = Unable to import { $filename }: file type not supported
|
importing-unable-to-import-filename = Unable to import { $filename }: file type not supported
|
||||||
|
importing-notes-that-could-not-be-imported = Notes that could not be imported as note type has changed: { $val }
|
||||||
|
|
|
@ -150,7 +150,7 @@ class Anki2Importer(Importer):
|
||||||
|
|
||||||
if dupesIgnored:
|
if dupesIgnored:
|
||||||
self.log.append(
|
self.log.append(
|
||||||
self.dst.tr.importing_notes_that_could_not_be_imported(
|
self.dst.tr.importing_notes_skipped_update_due_to_notetype(
|
||||||
val=len(dupesIgnored)
|
val=len(dupesIgnored)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -289,7 +289,7 @@ def log_queues(log: ImportLogWithChanges.Log) -> Tuple[LogQueue, ...]:
|
||||||
return (
|
return (
|
||||||
LogQueue(
|
LogQueue(
|
||||||
log.conflicting,
|
log.conflicting,
|
||||||
tr.importing_notes_that_could_not_be_imported,
|
tr.importing_notes_skipped_update_due_to_notetype,
|
||||||
tr.importing_skipped(),
|
tr.importing_skipped(),
|
||||||
),
|
),
|
||||||
LogQueue(
|
LogQueue(
|
||||||
|
|
|
@ -651,7 +651,7 @@ def running_in_sandbox():
|
||||||
)
|
)
|
||||||
!= ""
|
!= ""
|
||||||
)
|
)
|
||||||
in_snap = os.environ.get("SNAP") != ""
|
in_snap = bool(os.environ.get("SNAP"))
|
||||||
return in_flatpak or in_snap
|
return in_flatpak or in_snap
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -170,19 +170,30 @@ impl<'n> NoteContext<'n> {
|
||||||
|
|
||||||
for mut note in notes {
|
for mut note in notes {
|
||||||
incrementor.increment()?;
|
incrementor.increment()?;
|
||||||
if let Some(notetype_id) = self.remapped_notetypes.get(¬e.notetype_id) {
|
let remapped_notetype_id = self.remapped_notetypes.get(¬e.notetype_id);
|
||||||
if self.target_guids.contains_key(¬e.guid) {
|
if let Some(existing_note) = self.target_guids.get(¬e.guid) {
|
||||||
|
if existing_note.mtime < note.mtime {
|
||||||
|
if existing_note.notetype_id != note.notetype_id
|
||||||
|
|| remapped_notetype_id.is_some()
|
||||||
|
{
|
||||||
|
// Existing GUID with different notetype id, or changed notetype schema
|
||||||
self.imports.log_conflicting(note);
|
self.imports.log_conflicting(note);
|
||||||
} else {
|
} else {
|
||||||
note.notetype_id = *notetype_id;
|
self.update_note(note, existing_note.id)?;
|
||||||
self.add_note(note)?;
|
|
||||||
}
|
}
|
||||||
} else if let Some(&meta) = self.target_guids.get(¬e.guid) {
|
|
||||||
self.maybe_update_note(note, meta)?;
|
|
||||||
} else {
|
} else {
|
||||||
|
self.imports.log_duplicate(note, existing_note.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if let Some(remapped_ntid) = remapped_notetype_id {
|
||||||
|
// Notetypes have diverged, but this is a new note, so we can import
|
||||||
|
// with a new notetype id.
|
||||||
|
note.notetype_id = *remapped_ntid;
|
||||||
|
}
|
||||||
self.add_note(note)?;
|
self.add_note(note)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,19 +228,6 @@ impl<'n> NoteContext<'n> {
|
||||||
self.target_col.storage.get_note(nid)?.or_not_found(nid)
|
self.target_col.storage.get_note(nid)?.or_not_found(nid)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maybe_update_note(&mut self, note: Note, meta: NoteMeta) -> Result<()> {
|
|
||||||
if meta.mtime < note.mtime {
|
|
||||||
if meta.notetype_id == note.notetype_id {
|
|
||||||
self.update_note(note, meta.id)?;
|
|
||||||
} else {
|
|
||||||
self.imports.log_conflicting(note);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
self.imports.log_duplicate(note, meta.id);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_note(&mut self, mut note: Note, target_id: NoteId) -> Result<()> {
|
fn update_note(&mut self, mut note: Note, target_id: NoteId) -> Result<()> {
|
||||||
let source_id = note.id;
|
let source_id = note.id;
|
||||||
note.id = target_id;
|
note.id = target_id;
|
||||||
|
|
Loading…
Reference in a new issue