TagSpaces is an offline, open source, document manager with tagging support
Adding handling of not existing folders
Ilian5fa944dc0593
diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.jsindex 56e01746d..5221c625f 100644--- a/data/js/ioapi.chrome.js+++ b/data/js/ioapi.chrome.js@@ -165,34 +165,31 @@ IO-APIvar listDirectory = function(dirPath) {console.log("Listing directory: "+dirPath);if(nativeIO.isDirectory(dirPath)) {- //try {- var dirList = nativeIO.getDirEntries(dirPath);- var anotatedDirList = [];- for (var i=0; i < dirList.length; i++) {- var path = dirPath+getDirseparator()+dirList[i];- var isDir = nativeIO.isDirectory(path);- var fileSize = 0;- var lastDateModified = 0;- if(!isDir) {- fileSize = nativeIO.getFileSize(path);- if(isWin) {- lastDateModified = new Date(nativeIO.getFileLastDateModified(path)*1000);- }+ var dirList = nativeIO.getDirEntries(dirPath);+ var anotatedDirList = [];+ for (var i=0; i < dirList.length; i++) {+ var path = dirPath+getDirseparator()+dirList[i];+ var isDir = nativeIO.isDirectory(path);+ var fileSize = 0;+ var lastDateModified = 0;+ if(!isDir) {+ fileSize = nativeIO.getFileSize(path);+ if(isWin) {+ lastDateModified = new Date(nativeIO.getFileLastDateModified(path)*1000);}- anotatedDirList.push({- "name": dirList[i],- "isFile": !isDir,- "size": fileSize,- "lmdt": lastDateModified,- "path": path- });- }- TSPOSTIO.listDirectory(anotatedDirList);- //} catch(ex) {- // console.error("Directory listing failed "+ex);- //}+ }+ anotatedDirList.push({+ "name": dirList[i],+ "isFile": !isDir,+ "size": fileSize,+ "lmdt": lastDateModified,+ "path": path+ });+ }+ TSPOSTIO.listDirectory(anotatedDirList);} else {- console.error("Directory does not exists.");+ TSPOSTIO.errorOpeningPath();+ console.log("Directory does not exists.");}};diff --git a/data/js/ioapi.dropbox.js b/data/js/ioapi.dropbox.jsindex 8a643cf61..98fa17a7c 100644--- a/data/js/ioapi.dropbox.js+++ b/data/js/ioapi.dropbox.js@@ -100,6 +100,7 @@ define(function (require, exports, module) {//console.log("Dir content: " + JSON.stringify(entries));TSPOSTIO.listDirectory(anotatedDirList);} else {+ TSPOSTIO.errorOpeningPath();console.log("Dir List Error: " + err);}});diff --git a/data/js/ioapi.mozilla.js b/data/js/ioapi.mozilla.jsindex 88f7c5abd..d4a64933f 100644--- a/data/js/ioapi.mozilla.js+++ b/data/js/ioapi.mozilla.js@@ -64,7 +64,7 @@ define(function(require, exports, module) {case "loadTextFile":if(message.success){TSPOSTIO.loadTextFile(message.content);- } else {+ } else {TSCORE.updateLogger("File loading failed");}break;@@ -72,7 +72,7 @@ define(function(require, exports, module) {if(message.success){TSPOSTIO.listDirectory(message.content);} else {- TSCORE.updateLogger("List directory failed");+ TSPOSTIO.errorOpeningPath();}break;case "indexDirectory":diff --git a/data/js/ioapi.node.js b/data/js/ioapi.node.jsindex bd257519c..c80490124 100644--- a/data/js/ioapi.node.js+++ b/data/js/ioapi.node.js@@ -190,6 +190,7 @@ define(function(require, exports, module) {try {fs.readdir(dirPath, function(error, dirList) {if (error) {+ TSPOSTIO.errorOpeningPath();console.log("Listing directory: "+dirPath+" failed "+error);return;}@@ -210,6 +211,7 @@ define(function(require, exports, module) {TSPOSTIO.listDirectory(anotatedDirList);});} catch(ex) {+ TSPOSTIO.errorOpeningPath();console.error("Listing directory "+dirPath+" failed "+ex);}};diff --git a/data/js/postioapi.js b/data/js/postioapi.jsindex 137bf2140..9705b8258 100644--- a/data/js/postioapi.js+++ b/data/js/postioapi.js@@ -22,8 +22,11 @@ define(function(require, exports, module) {};exports.renameFile = function(oldFilePath, newFilePath) {+ var lastOpenedFile = TSCORE.FileOpener.getOpenedFilePath();++ console.log("Last opened Filename: "+lastOpenedFile);// TODO handle case in which a file opened for editing and a tag has been added- if(TSCORE.FileOpener.isFileOpened() && (oldFilePath == TSCORE.FileOpener.getOpenedFilePath()) ) {+ if(TSCORE.FileOpener.isFileOpened() && (oldFilePath == lastOpenedFile) ) {TSCORE.FileOpener.openFile(newFilePath);}// TODO to be replaced with a function which replaces the@@ -46,6 +49,12 @@ define(function(require, exports, module) {TSCORE.PerspectiveManager.updateFileBrowserData(anotatedDirList);TSCORE.updateSubDirs(anotatedDirList);};++ exports.errorOpeningPath = function() {+ TSCORE.showAlertDialog("Error occured while opening a path! Currently opened location will be closed.");+ TSCORE.closeCurrentLocation();+ TSCORE.PerspectiveManager.updateFileBrowserData([]);+ };exports.deleteElement = function() {TSCORE.PerspectiveManager.refreshFileListContainer();@@ -60,6 +69,8 @@ define(function(require, exports, module) {var dirName = TSCORE.TagUtils.extractContainingDirectoryName(dirPath+TSCORE.TagUtils.DIR_SEPARATOR);$("#connectionName").val(dirName);$("#folderLocation").val(dirPath);+ //$("#connectionName2").val(dirName);+ $("#folderLocation2").val(dirPath);};exports.openDirectory = function(dirPath) {