TagSpaces is an offline, open source, document manager with tagging support
OSX issue with renaming workarrounded
uggrock94a04f22c46a
diff --git a/lib/ioutils.js b/lib/ioutils.jsindex af7c43487..f9a8ff7f7 100644--- a/lib/ioutils.js+++ b/lib/ioutils.js@@ -311,31 +311,31 @@ exports.deleteElement = function deleteElement(path, worker) {exports.rename = function rename(filePath, newFilePath, worker) {console.log("Renaming file: "+filePath+" to "+newFilePath);// Checks if the file already exists.- if(!filesIO.exists(newFilePath)) {+ console.log("Renaming on "+runtime.OS);++ if(!filesIO.exists(newFilePath)) {try {// TODO Remove the OSX custom code after https://bugzilla.mozilla.org/show_bug.cgi?id=913663 is fixed- if(runtime.OS.toLowerCase().indexOf("mac")>=0) {- console.log("Renaming under macos");+ if(runtime.OS.toLowerCase().indexOf("darwin")>=0) {+ console.log("Renaming under macos ");- //var url = Cc["@mozilla.org/file/local;1"].newURI(filePath, null, null);- //if (!url || !url.schemeIs("file")) throw "Expected a file URL.";- //var binaryFile = url.QueryInterface(Ci.nsIFileURL).file;-- var binaryFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);+ var binaryFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);binaryFile.initWithPath( filePath );-+ console.log("Init File: "+filePath);+var istream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);istream.init(binaryFile, -1, -1, false);var bstream = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);bstream.setInputStream(istream);-- var aFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);- aFile.initWithPath( newFilePath );- aFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);-+ var binaryStream = bstream.readBytes(bstream.available());++ var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);+ file.initWithPath(newFilePath);+ console.log("InitFile: "+newFilePath);+var stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);- stream.init(aFile, 0x04 | 0x08 | 0x20, 0600, 0); // readwrite, create, truncate- stream.write(bstream,bstream.length);+ stream.init(file, 0x04 | 0x08 | 0x20, 0600, 0); // readwrite, create, truncate+ stream.write(binaryStream,binaryStream.length);if (stream instanceof Ci.nsISafeOutputStream) {stream.finish();} else {@@ -347,7 +347,7 @@ exports.rename = function rename(filePath, newFilePath, worker) {} else {var targetDir;var targetFileName;- // Detecting WINNT os+ // Detecting WIN osif(runtime.OS.toLowerCase().indexOf("win")!=-1) {targetDir = newFilePath.substring(0,newFilePath.lastIndexOf("\\"));targetFileName = newFilePath.substring(newFilePath.lastIndexOf("\\")+1,newFilePath.length);