now using .tar export to initialize DB instead of direct DB dumps

This commit is contained in:
azivner
2018-11-16 14:36:50 +01:00
parent 5b9a1ef0e9
commit 94565e3ec0
14 changed files with 75 additions and 538 deletions

View File

@@ -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);
}

View File

@@ -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);