mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
now using .tar export to initialize DB instead of direct DB dumps
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
const noteService = require('../../services/notes');
|
||||
const parseString = require('xml2js').parseString;
|
||||
|
||||
async function importOpml(file, parentNote) {
|
||||
async function importOpml(fileBuffer, parentNote) {
|
||||
const xml = await new Promise(function(resolve, reject)
|
||||
{
|
||||
parseString(file.buffer, function (err, result) {
|
||||
parseString(fileBuffer, function (err, result) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,8 @@ const stream = require('stream');
|
||||
const path = require('path');
|
||||
const commonmark = require('commonmark');
|
||||
|
||||
/**
|
||||
* Complication of this export is the need to balance two needs:
|
||||
* -
|
||||
*/
|
||||
async function importTar(file, parentNote) {
|
||||
const files = await parseImportFile(file);
|
||||
async function importTar(fileBuffer, parentNote) {
|
||||
const files = await parseImportFile(fileBuffer);
|
||||
|
||||
const ctx = {
|
||||
// maps from original noteId (in tar file) to newly generated noteId
|
||||
@@ -96,7 +92,7 @@ function getFileName(name) {
|
||||
return {name, key};
|
||||
}
|
||||
|
||||
async function parseImportFile(file) {
|
||||
async function parseImportFile(fileBuffer) {
|
||||
const fileMap = {};
|
||||
const files = [];
|
||||
|
||||
@@ -165,7 +161,7 @@ async function parseImportFile(file) {
|
||||
});
|
||||
|
||||
const bufferStream = new stream.PassThrough();
|
||||
bufferStream.end(file.buffer);
|
||||
bufferStream.end(fileBuffer);
|
||||
|
||||
bufferStream.pipe(extract);
|
||||
});
|
||||
@@ -224,7 +220,8 @@ async function importNotes(ctx, files, parentNoteId) {
|
||||
noteId: ctx.getNewNoteId(file.meta.noteId),
|
||||
type: file.meta.type,
|
||||
mime: file.meta.mime,
|
||||
prefix: file.meta.prefix
|
||||
prefix: file.meta.prefix,
|
||||
isExpanded: !!file.meta.isExpanded
|
||||
})).note;
|
||||
|
||||
ctx.createdNoteIds.push(note.noteId);
|
||||
|
||||
Reference in New Issue
Block a user