import WIP

This commit is contained in:
zadam
2023-05-09 00:05:27 +02:00
parent 626af84f42
commit ff5d3a5f0c
12 changed files with 80 additions and 34 deletions

View File

@@ -185,7 +185,7 @@ function deleteBranch(req) {
const eraseNotes = req.query.eraseNotes === 'true';
const branch = becca.getBranchOrThrow(req.params.branchId);
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
const taskContext = TaskContext.getInstance(req.query.taskId, 'deleteNotes');
const deleteId = utils.randomString(10);
let noteDeleted;

View File

@@ -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 = {

View File

@@ -62,7 +62,7 @@ function deleteNote(req) {
const note = becca.getNote(noteId);
const taskContext = TaskContext.getInstance(taskId, 'delete-notes');
const taskContext = TaskContext.getInstance(taskId, 'deleteNotes');
note.deleteNote(deleteId, taskContext);