Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1455)

Unified Diff: tools/gn/function_write_file.cc

Issue 1126193005: Check for inputs not generated by deps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/filesystem_utils.cc ('k') | tools/gn/function_write_file_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/function_write_file.cc
diff --git a/tools/gn/function_write_file.cc b/tools/gn/function_write_file.cc
index 8a6fee31e1c93b01269d99bdf1917c5d2b956369..45387a3967555394005d7455117160379055f25c 100644
--- a/tools/gn/function_write_file.cc
+++ b/tools/gn/function_write_file.cc
@@ -21,14 +21,18 @@ namespace functions {
namespace {
// On Windows, provide a custom implementation of base::WriteFile. Sometimes
-// the base version would fail, and this alternate implementation provides
-// additional logging. See http://crbug.com/468437
+// the base version fails, especially on the bots. The guess is that Windows
+// Defender or other antivirus programs still have the file open (after
+// checking for the read) when the write happens immediately after. This
+// version opens with FILE_SHARE_READ (normally not what you want when
+// replacing the entire contents of the file) which lets us continue even if
+// another program has the file open for reading. See http://crbug.com/468437
#if defined(OS_WIN)
int DoWriteFile(const base::FilePath& filename, const char* data, int size) {
base::win::ScopedHandle file(::CreateFile(
filename.value().c_str(),
GENERIC_WRITE,
- FILE_SHARE_READ, // Not present in the base version, speculative fix.
+ FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
0,
@@ -109,6 +113,7 @@ Value RunWriteFile(Scope* scope,
scope->settings()->build_settings()->build_dir(),
source_file.value(), args[0].origin(), err))
return Value();
+ g_scheduler->AddWrittenFile(source_file); // Track that we wrote this file.
// Compute output.
std::ostringstream contents;
« no previous file with comments | « tools/gn/filesystem_utils.cc ('k') | tools/gn/function_write_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698