ancillary => attachment

This commit is contained in:
zadam
2023-03-16 11:03:28 +01:00
parent e16bedfab4
commit dc97400dbf
20 changed files with 161 additions and 161 deletions

View File

@@ -14,7 +14,7 @@ const treeService = require("../tree");
const yauzl = require("yauzl");
const htmlSanitizer = require('../html_sanitizer');
const becca = require("../../becca/becca");
const BNoteAncillary = require("../../becca/entities/bnote_attachment.js");
const BNoteAttachment = require("../../becca/entities/bnote_attachment.js");
/**
* @param {TaskContext} taskContext
@@ -65,7 +65,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
};
let parent;
let ancillaryMeta = false;
let attachmentMeta = false;
for (const segment of pathSegments) {
if (!cursor || !cursor.children || cursor.children.length === 0) {
@@ -77,10 +77,10 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
if (!cursor) {
for (const file of parent.children) {
for (const ancillary of file.ancillaries || []) {
if (ancillary.dataFileName === segment) {
for (const attachment of file.attachments || []) {
if (attachment.dataFileName === segment) {
cursor = file;
ancillaryMeta = ancillary;
attachmentMeta = attachment;
break;
}
}
@@ -95,7 +95,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
return {
parentNoteMeta: parent,
noteMeta: cursor,
ancillaryMeta
attachmentMeta
};
}
@@ -370,7 +370,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
}
function saveNote(filePath, content) {
const {parentNoteMeta, noteMeta, ancillaryMeta} = getMeta(filePath);
const {parentNoteMeta, noteMeta, attachmentMeta} = getMeta(filePath);
if (noteMeta?.noImport) {
return;
@@ -378,14 +378,14 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
const noteId = getNoteId(noteMeta, filePath);
if (ancillaryMeta) {
const noteAncillary = new BNoteAncillary({
if (attachmentMeta) {
const noteAttachment = new BNoteAttachment({
noteId,
name: ancillaryMeta.name,
mime: ancillaryMeta.mime
name: attachmentMeta.name,
mime: attachmentMeta.mime
});
noteAncillary.setContent(content);
noteAttachment.setContent(content);
return;
}