From 83d6c2970fb8f816fe957c8cd5e318cacbf901fd Mon Sep 17 00:00:00 2001 From: azivner Date: Sat, 3 Mar 2018 09:32:21 -0500 Subject: [PATCH] added versioning to the metadata files in export tars --- src/routes/api/export.js | 1 + src/routes/api/import.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/routes/api/export.js b/src/routes/api/export.js index 06a850f6b..6c6c2926a 100644 --- a/src/routes/api/export.js +++ b/src/routes/api/export.js @@ -64,6 +64,7 @@ async function exportNote(noteTreeId, directory, pack, repo) { async function getMetadata(note) { return { + version: 1, title: note.title, type: note.type, mime: note.mime, diff --git a/src/routes/api/import.js b/src/routes/api/import.js index b64db03b0..dfbed493e 100644 --- a/src/routes/api/import.js +++ b/src/routes/api/import.js @@ -112,6 +112,10 @@ router.post('/:parentNoteId', auth.checkApiAuthOrElectron, multer.single('upload async function importNotes(files, parentNoteId, sourceId) { for (const file of files) { + if (file.meta.version !== 1) { + throw new Error("Can't read meta data version " + file.meta.version); + } + if (file.meta.type !== 'file') { file.data = file.data.toString("UTF-8"); }