Bug 961080 - Apply umask upon completion of downloads. r=amadini, a=sledru
authorZack Weinberg <zackw@panix.com>
Fri, 20 Jun 2014 19:54:06 -0400
changeset 200689 0be5734ba2895b1bdb96d922cbbdfcc7681b9015
parent 200688 aae3600e0e640950bbd31b6359689c3efcbb7643
child 200690 068f732a0dc4d799a44be13248df543f947fae6d
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersamadini, sledru
bugs961080
milestone31.0
Bug 961080 - Apply umask upon completion of downloads. r=amadini, a=sledru
toolkit/components/jsdownloads/src/DownloadIntegration.jsm
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -606,16 +606,27 @@ this.DownloadIntegration = {
           // specific error.
           if (!(ex instanceof OS.File.Error) || ex.winLastError != 123) {
             Cu.reportError(ex);
           }
         }
       }
 #endif
 
+      // Now that the file is completely downloaded, mark it
+      // accessible by other users on this system, if the user's
+      // global preferences so indicate.  (On Unix, this applies the
+      // umask.  On Windows, currently does nothing.)
+      // Errors should be reported, but are not fatal.
+      try {
+        yield OS.File.setPermissions(aDownload.target.path);
+      } catch (ex) {
+        Cu.reportError(ex);
+      }
+
       gDownloadPlatform.downloadDone(NetUtil.newURI(aDownload.source.url),
                                      new FileUtils.File(aDownload.target.path),
                                      aDownload.contentType,
                                      aDownload.source.isPrivate);
       this.downloadDoneCalled = true;
     }.bind(this));
   },