Bug 729212. (Av1a) abTrees.js: Use a safe-file-output-stream. r+moa=Mnyromyr a=Callek
authorSerge Gautherie <sgautherie.bz@free.fr>
Wed, 07 Mar 2012 22:32:07 +0100
changeset 11679 7b7fa546c0c31bc9e4b049d48ab38a3feae314d8
parent 11678 0c8b3aab1faaed831132be042230c584dd9f909a
child 11680 da05932da8513e1a6039013fc2e0111385498602
push id6
push userbienvenu@nventure.com
push dateWed, 16 May 2012 22:24:51 +0000
treeherdertry-comm-central@ac395aea3008 [default view] [failures only]
reviewersCallek
bugs729212
Bug 729212. (Av1a) abTrees.js: Use a safe-file-output-stream. r+moa=Mnyromyr a=Callek
suite/mailnews/addrbook/abTrees.js
--- a/suite/mailnews/addrbook/abTrees.js
+++ b/suite/mailnews/addrbook/abTrees.js
@@ -158,21 +158,21 @@ directoryTreeView.prototype =
     if (aJSONFile)
     {
       // Write out our json file...
       let data = JSON.stringify(this._persistOpenMap);
       let file = Components.classes["@mozilla.org/file/directory_service;1"]
                            .getService(Components.interfaces.nsIProperties)
                            .get("ProfD", Components.interfaces.nsIFile);
       file.append(aJSONFile);
-      let foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
+      let foStream = Components.classes["@mozilla.org/network/safe-file-output-stream;1"]
                                .createInstance(Components.interfaces.nsIFileOutputStream);
-
       foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0);
       foStream.write(data, data.length);
+      foStream.QueryInterface(Components.interfaces.nsISafeOutputStream).finish();
       foStream.close();
     }
   },
 
   // Override the dnd methods for those functions in abDragDrop.js
   canDrop: function dtv_canDrop(aIndex, aOrientation)
   {
     return abDirTreeObserver.canDrop(aIndex, aOrientation);