From fa5cebda6d7d6e2614adf9837e64ed7a3d7a5ab9 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Tue, 15 May 2018 15:45:46 +0900 Subject: [PATCH] Fix moving note with attachments between different storage --- browser/main/lib/dataApi/moveNote.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/browser/main/lib/dataApi/moveNote.js b/browser/main/lib/dataApi/moveNote.js index cffb5c53..fbfd375e 100644 --- a/browser/main/lib/dataApi/moveNote.js +++ b/browser/main/lib/dataApi/moveNote.js @@ -6,7 +6,6 @@ const CSON = require('@rokt33r/season') const keygen = require('browser/lib/keygen') const sander = require('sander') const { findStorage } = require('browser/lib/findStorage') -const copyImage = require('./copyImage') function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) { let oldStorage, newStorage @@ -70,16 +69,17 @@ function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) { .then(function moveImages (noteData) { if (oldStorage.path === newStorage.path) return noteData - const searchImagesRegex = /!\[.*?]\(\s*?\/:storage\/(.*\.\S*?)\)/gi + const searchImagesRegex = /!\[.*\]\(:storage\/(.+)\)/gi let match = searchImagesRegex.exec(noteData.content) const moveTasks = [] while (match != null) { const [, filename] = match - const oldPath = path.join(oldStorage.path, 'images', filename) + const oldPath = path.join(oldStorage.path, 'attachments', filename) + const newPath = path.join(newStorage.path, 'attachments', filename) // TODO: ehhc: attachmentManagement moveTasks.push( - copyImage(oldPath, noteData.storage, false) + sander.copyFile(oldPath).to(newPath) .then(() => { fs.unlinkSync(oldPath) })