Bug 961080: apply umask upon completion of downloads. r=amadini
authorZack Weinberg <zackw@panix.com>
Fri, 20 Jun 2014 19:54:06 -0400
changeset 189876 c6426f08a82875f128b25aa1c43624b4e99ecf0f
parent 189875 a5714e1eafca8447ffe7e478974f97610921380a
child 189877 26b95471c5f8f41dfcb207c9358ae70d0f7ad434
push id45175
push userzackw@panix.com
push dateFri, 20 Jun 2014 23:54:12 +0000
treeherdermozilla-inbound@c6426f08a828 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersamadini
bugs961080
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 961080: apply umask upon completion of downloads. r=amadini
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));
   },