From 25f8df1e0359df1915f28c99651071a4fb7d4c21 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 3 Sep 2018 17:08:34 +0200 Subject: [PATCH] fix import for tars generated outside of trilium --- src/routes/api/import.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/routes/api/import.js b/src/routes/api/import.js index 7469c44c6..09b888764 100644 --- a/src/routes/api/import.js +++ b/src/routes/api/import.js @@ -151,10 +151,15 @@ async function parseImportFile(file) { if (header.type === 'file') { ({name, key} = getFileName(header.name)); } - else { - name = header.name; + else if (header.type === 'directory') { + // directory entries in tar often end with directory separator + name = (header.name.endsWith("/") || header.name.endsWith("\\")) ? header.name.substr(0, header.name.length - 1) : header.name; key = 'directory'; } + else { + log.error("Unrecognized tar entry: " + JSON.stringify(header)); + return; + } let file = fileMap[name];