importing of cloned notes should not depend on ZIP listing order, fixes #2440

This commit is contained in:
zadam
2021-12-15 22:36:45 +01:00
parent a81ea3771f
commit 074eb1c02f
2 changed files with 15 additions and 3 deletions

View File

@@ -351,7 +351,19 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
let note = becca.getNote(noteId);
const isProtected = importRootNote.isProtected && protectedSessionService.isProtectedSessionAvailable();
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);
}
else {
@@ -367,7 +379,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
// root notePosition should be ignored since it relates to original document
// now import root should be placed after existing notes into new parent
notePosition: (noteMeta && firstNote) ? noteMeta.notePosition : undefined,
isProtected: importRootNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
isProtected: isProtected,
}));
createdNoteIds[note.noteId] = true;