Skip to content

TagSpaces is an offline, open source, document manager with tagging support

disabling directory watching on file rename

uggrock0d1147fa531b
diff --git a/data/electron/electron.api.js b/data/electron/electron.api.js
index 8bea1a967..8794a47e6 100644
--- a/data/electron/electron.api.js
+++ b/data/electron/electron.api.js
@@ -715,6 +715,7 @@ define(function(require, exports, module) {
*/
function renameFilePromise(filePath, newFilePath) {
console.log("Renaming file: " + filePath + " to " + newFilePath);
+ stopWatchingDirectories();
return new Promise(function(resolve, reject) {
if (filePath === newFilePath) {
reject($.i18n.t("ns.common:fileTheSame"), $.i18n.t("ns.common:fileNotMoved"));
@@ -722,6 +723,9 @@ define(function(require, exports, module) {
} else if (fs.lstatSync(filePath).isDirectory()) {
reject($.i18n.t("ns.common:fileIsDirectory", {fileName: filePath}));
return;
+ } else if (!fs.existsSync(filePath)) {
+ reject("Source file does not exists " +filePath, $.i18n.t("ns.common:fileRenameFailed"));
+ return;
} else if (fs.existsSync(newFilePath)) {
reject($.i18n.t("ns.common:fileExists", {fileName: newFilePath}), $.i18n.t("ns.common:fileRenameFailed"));
return;