mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
Note id, not guid of conflicting notes
This commit is contained in:
parent
94a6cdd6ed
commit
48bc6627b1
1 changed files with 9 additions and 6 deletions
|
@ -44,7 +44,9 @@ struct Context<'a> {
|
||||||
/// original, normalized file name → (refererenced on import material,
|
/// original, normalized file name → (refererenced on import material,
|
||||||
/// entry with possibly remapped file name)
|
/// entry with possibly remapped file name)
|
||||||
used_media_entries: HashMap<String, (bool, SafeMediaEntry)>,
|
used_media_entries: HashMap<String, (bool, SafeMediaEntry)>,
|
||||||
conflicting_notes: HashSet<String>,
|
/// Source notes that cannot be imported, because notes with the same guid
|
||||||
|
/// exist in the target, but their notetypes don't match.
|
||||||
|
conflicting_notes: HashSet<NoteId>,
|
||||||
normalize_notes: bool,
|
normalize_notes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,14 +222,14 @@ impl<'a> Context<'a> {
|
||||||
for mut note in mem::take(&mut self.data.notes) {
|
for mut note in mem::take(&mut self.data.notes) {
|
||||||
if let Some(notetype_id) = self.remapped_notetypes.get(¬e.notetype_id) {
|
if let Some(notetype_id) = self.remapped_notetypes.get(¬e.notetype_id) {
|
||||||
if self.guid_map.contains_key(¬e.guid) {
|
if self.guid_map.contains_key(¬e.guid) {
|
||||||
self.conflicting_notes.insert(note.guid);
|
self.conflicting_notes.insert(note.id);
|
||||||
// TODO: Log ignore
|
// TODO: Log ignore
|
||||||
} else {
|
} else {
|
||||||
note.notetype_id = *notetype_id;
|
note.notetype_id = *notetype_id;
|
||||||
self.add_note(&mut note)?;
|
self.add_note(&mut note)?;
|
||||||
}
|
}
|
||||||
} else if let Some(&meta) = self.guid_map.get(¬e.guid) {
|
} else if let Some(&meta) = self.guid_map.get(¬e.guid) {
|
||||||
self.maybe_update_note(note, meta)?;
|
self.maybe_update_note(&mut note, meta)?;
|
||||||
} else {
|
} else {
|
||||||
self.add_note(&mut note)?;
|
self.add_note(&mut note)?;
|
||||||
}
|
}
|
||||||
|
@ -261,13 +263,14 @@ impl<'a> Context<'a> {
|
||||||
.ok_or(AnkiError::NotFound)
|
.ok_or(AnkiError::NotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maybe_update_note(&mut self, mut note: Note, meta: NoteMeta) -> Result<()> {
|
fn maybe_update_note(&mut self, note: &mut Note, meta: NoteMeta) -> Result<()> {
|
||||||
if meta.mtime < note.mtime {
|
if meta.mtime < note.mtime {
|
||||||
if meta.notetype_id == note.notetype_id {
|
if meta.notetype_id == note.notetype_id {
|
||||||
|
self.remapped_notes.insert(note.id, meta.id);
|
||||||
note.id = meta.id;
|
note.id = meta.id;
|
||||||
self.update_note(&mut note)?;
|
self.update_note(note)?;
|
||||||
} else {
|
} else {
|
||||||
self.conflicting_notes.insert(note.guid);
|
self.conflicting_notes.insert(note.id);
|
||||||
// TODO: Log ignore
|
// TODO: Log ignore
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue