mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
import WIP
This commit is contained in:
@@ -44,7 +44,7 @@ async function importNotesToBranch(req) {
|
||||
|
||||
let note; // typically root of the import - client can show it after finishing the import
|
||||
|
||||
const taskContext = TaskContext.getInstance(taskId, 'import', options);
|
||||
const taskContext = TaskContext.getInstance(taskId, 'importNotes', options);
|
||||
|
||||
try {
|
||||
if (extension === '.zip' && options.explodeArchives) {
|
||||
@@ -95,22 +95,12 @@ async function importAttachmentsToNote(req) {
|
||||
}
|
||||
|
||||
const parentNote = becca.getNoteOrThrow(parentNoteId);
|
||||
const taskContext = TaskContext.getInstance(taskId, 'importAttachment', options);
|
||||
|
||||
// running all the event handlers on imported notes (and attributes) is slow
|
||||
// and may produce unintended consequences
|
||||
cls.disableEntityEvents();
|
||||
|
||||
// eliminate flickering during import
|
||||
cls.ignoreEntityChangeIds();
|
||||
|
||||
let note; // typically root of the import - client can show it after finishing the import
|
||||
|
||||
const taskContext = TaskContext.getInstance(taskId, 'import', options);
|
||||
// unlike in note import we let the events run, because a huge number of attachments is not likely
|
||||
|
||||
try {
|
||||
// FIXME
|
||||
|
||||
note = await singleImportService.importSingleFile(taskContext, file, parentNote);
|
||||
await singleImportService.importAttachment(taskContext, file, parentNote);
|
||||
}
|
||||
catch (e) {
|
||||
const message = `Import failed with following error: '${e.message}'. More details might be in the logs.`;
|
||||
@@ -124,15 +114,9 @@ async function importAttachmentsToNote(req) {
|
||||
if (last === "true") {
|
||||
// small timeout to avoid race condition (the message is received before the transaction is committed)
|
||||
setTimeout(() => taskContext.taskSucceeded({
|
||||
parentNoteId: parentNoteId,
|
||||
importedNoteId: note.noteId
|
||||
parentNoteId: parentNoteId
|
||||
}), 1000);
|
||||
}
|
||||
|
||||
// import has deactivated note events so becca is not updated, instead we force it to reload
|
||||
beccaLoader.load();
|
||||
|
||||
return note.getPojo();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user