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 207514 f571f0ec2ad31168db990a6f154a8017020b244f
parent 207513 61e420e597b0e3a43daf2a1595182ef21a181d57
child 207515 ee6dc0c0c2d754aaabf1fc0dfe2d491f163f78ef
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersamadini, sledru
bugs961080
milestone32.0a2
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));
   },