TagSpaces is an offline, open source, document manager with tagging support
Correct meta file move
Borislav Sapundzhieveb0168aaedc2
diff --git a/data/js/meta.js b/data/js/meta.jsindex d276a0d09..7345f1dca 100644--- a/data/js/meta.js+++ b/data/js/meta.js@@ -63,11 +63,24 @@ define(function(require, exports, module) {TSCORE.metaFileList.forEach(function(element, index) {if (element.name.indexOf(name) >= 0) {if (newFileName) {+ var pathOld = TSCORE.Utils.dirName(oldFileName);+ var pathNew = TSCORE.Utils.dirName(newFileName);+ var path = TSCORE.currentPath;++ if(pathOld != pathNew) {+ path = pathNew;+ }var newName = TSCORE.Utils.baseName(newFileName) + "." + element.name.split('.').pop();- var newFilePath = TSCORE.currentPath + TSCORE.dirSeparator + TSCORE.metaFolder + TSCORE.dirSeparator + newName;+ var newFilePath = path + TSCORE.dirSeparator + TSCORE.metaFolder + TSCORE.dirSeparator + newName;TSCORE.IO.renameFile(element.path, newFilePath);- element.name = newName;- element.path = newFilePath;++ if(pathOld == TSCORE.currentPath) {+ element.name = newName;+ element.path = newFilePath;+ } else {+ TSCORE.metaFileList.splice(index, 1);+ }+} else {TSCORE.IO.deleteElement(element.path);TSCORE.metaFileList.splice(index, 1);diff --git a/data/js/utils.js b/data/js/utils.jsindex 13ffeb9a5..4f51d6d9f 100644--- a/data/js/utils.js+++ b/data/js/utils.js@@ -47,7 +47,12 @@ define(function(require, exports, module) {var baseName = function(dirPath) {var fileName = dirPath.substring(dirPath.lastIndexOf("/") + 1, dirPath.length);- return fileName ? fileName : dirPath;+ return fileName ? fileName : dirPath;+ };++ var dirName = function(dirPath) {+ return dirPath.replace(/\/[^\/]*$/,'');+ //return dirPath.match( /(.*)[/\]/)[1];};exports.arrayBufferToDataURL = arrayBufferToDataURL;@@ -56,4 +61,5 @@ define(function(require, exports, module) {exports.getBase64Image = getBase64Image;exports.arrayBufferToStr = arrayBufferToStr;exports.baseName = baseName;+ exports.dirName = dirName;});