TagSpaces is an offline, open source, document manager with tagging support
Unifing of the format of the return object from listDirectory and scanDirectory
uggrock4b4b34406fce
diff --git a/lib/ioutils.js b/lib/ioutils.jsindex 9f7150c43..e856a0402 100644--- a/lib/ioutils.js+++ b/lib/ioutils.js@@ -160,6 +160,39 @@ function scanDirectory(dirPath, index) {}}+// TODO use scanDirectory+exports.listDirectory = function listDirectory(dirPath, worker) {+ console.debug("Listing directory: "+dirPath);+ try {+ var dirList = filesIO.list(dirPath);+ var anotatedDirList = [];+ for (var i=0; i < dirList.length; i++) {+ var path = filesIO.join(dirPath,dirList[i]);+ var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);+ file.initWithPath(filesIO.join(dirPath,dirList[i]));+ anotatedDirList.push({+ "name": file.leafName,+ "type": file.isFile()?"file":"directory",+ "size": file.fileSize,+ "lmdt": file.lastModifiedTime,+ "path": path+ });+ }+ worker.postMessage({+ "command": "listDirectory",+ "success": true,+ "content": anotatedDirList+ });+ console.debug("Listing directory successful!");+ } catch(ex) {+ console.error("Listing directory failed "+ex);+ worker.postMessage({+ "command": "listDirectory",+ "success": false+ });+ }+}+exports.createDirectory = function createDirectory(filePath, worker) {console.debug("Creating directory: "+filePath);try {@@ -197,36 +230,6 @@ exports.loadTextFile = function loadTextFile(filePath, worker) {}}-exports.listDirectory = function listDirectory(dirPath, worker) {- console.debug("Listing directory: "+dirPath);- try {- var dirList = filesIO.list(dirPath);- var anotatedDirList = [];- for (var i=0; i < dirList.length; i++) {- var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);- file.initWithPath(filesIO.join(dirPath,dirList[i]));- anotatedDirList.push({- "name": file.leafName,- "type": file.isFile()?"file":"directory",- "size": file.fileSize,- "lmdt": file.lastModifiedTime- });- }- worker.postMessage({- "command": "listDirectory",- "success": true,- "content": anotatedDirList- });- console.debug("Listing directory successful!");- } catch(ex) {- console.error("Listing directory failed "+ex);- worker.postMessage({- "command": "listDirectory",- "success": false- });- }-}-exports.getSubdirs = function getSubdirs(dirPath, worker) {console.debug("Getting subdirectories: "+dirPath);try {