Fix file permissions in save_as mode on POSIX.
BUG=36107
TEST=Check 'Ask where to save each file before downloading' in 'Under the Hood' preference, start a download and check the file permission.
Review URL: http://codereview.chromium.org/672019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40977 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/download/download_file.cc b/chrome/browser/download/download_file.cc
index a6196470..50af0f5f 100644
--- a/chrome/browser/download/download_file.cc
+++ b/chrome/browser/download/download_file.cc
@@ -126,6 +126,10 @@
// 600 to |new_path|. Here, we try to fix up the destination file with
// appropriate permissions.
struct stat st;
+ // First check the file existence and create an empty file if it doesn't
+ // exist.
+ if (!file_util::PathExists(new_path))
+ file_util::WriteFile(new_path, "", 0);
bool stat_succeeded = (stat(new_path.value().c_str(), &st) == 0);
// TODO(estade): Move() falls back to copying and deleting when a simple