mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
importing of cloned notes should not depend on ZIP listing order, fixes #2440
This commit is contained in:
parent
a81ea3771f
commit
074eb1c02f
@ -84,7 +84,7 @@ class Branch extends AbstractEntity {
|
|||||||
/** @returns {Note} */
|
/** @returns {Note} */
|
||||||
get childNote() {
|
get childNote() {
|
||||||
if (!(this.noteId in this.becca.notes)) {
|
if (!(this.noteId in this.becca.notes)) {
|
||||||
// entities can come out of order in sync, create skeleton which will be filled later
|
// entities can come out of order in sync/import, create skeleton which will be filled later
|
||||||
this.becca.addNote(this.noteId, new Note({noteId: this.noteId}));
|
this.becca.addNote(this.noteId, new Note({noteId: this.noteId}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class Branch extends AbstractEntity {
|
|||||||
/** @returns {Note} */
|
/** @returns {Note} */
|
||||||
get parentNote() {
|
get parentNote() {
|
||||||
if (!(this.parentNoteId in this.becca.notes)) {
|
if (!(this.parentNoteId in this.becca.notes)) {
|
||||||
// entities can come out of order in sync, create skeleton which will be filled later
|
// entities can come out of order in sync/import, create skeleton which will be filled later
|
||||||
this.becca.addNote(this.parentNoteId, new Note({noteId: this.parentNoteId}));
|
this.becca.addNote(this.parentNoteId, new Note({noteId: this.parentNoteId}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +351,19 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
|||||||
|
|
||||||
let note = becca.getNote(noteId);
|
let note = becca.getNote(noteId);
|
||||||
|
|
||||||
|
const isProtected = importRootNote.isProtected && protectedSessionService.isProtectedSessionAvailable();
|
||||||
|
|
||||||
if (note) {
|
if (note) {
|
||||||
|
// only skeleton was created because of altered order of cloned notes in ZIP, we need to update
|
||||||
|
// https://github.com/zadam/trilium/issues/2440
|
||||||
|
if (note.type === undefined) {
|
||||||
|
note.type = type;
|
||||||
|
note.mime = mime;
|
||||||
|
note.title = noteTitle;
|
||||||
|
note.isProtected = isProtected;
|
||||||
|
note.save();
|
||||||
|
}
|
||||||
|
|
||||||
note.setContent(content);
|
note.setContent(content);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -367,7 +379,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
|||||||
// root notePosition should be ignored since it relates to original document
|
// root notePosition should be ignored since it relates to original document
|
||||||
// now import root should be placed after existing notes into new parent
|
// now import root should be placed after existing notes into new parent
|
||||||
notePosition: (noteMeta && firstNote) ? noteMeta.notePosition : undefined,
|
notePosition: (noteMeta && firstNote) ? noteMeta.notePosition : undefined,
|
||||||
isProtected: importRootNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
|
isProtected: isProtected,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
createdNoteIds[note.noteId] = true;
|
createdNoteIds[note.noteId] = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user