From a2d949f9d2b3d360c35558e0360ddddd91a71f4f Mon Sep 17 00:00:00 2001 From: Herman Venter Date: Sun, 9 Jun 2013 17:58:03 -0700 Subject: [PATCH] Do not recreate the debugger options file. The code for reading in the personalized debugger options, always wrote out the file to account for the case where there may not be a file in the first place. This is not necessary and can lead to the file being changed when running various kinds of debugger tests. Since the tests use a checked in file, it is not desirable for the file to change as a result of a test run. With this change, the file will only be written out when it is missing in the first place. There are still some scenarios where it is possible to write a test that will change the file. Currently no such tests exist. Also, in those scenarios, the test may well want to verify that the file is changed, so more work will needed later on. Right now, that can wait. --- hphp/runtime/debugger/debugger_client.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hphp/runtime/debugger/debugger_client.cpp b/hphp/runtime/debugger/debugger_client.cpp index 72ec95560..b5828b014 100644 --- a/hphp/runtime/debugger/debugger_client.cpp +++ b/hphp/runtime/debugger/debugger_client.cpp @@ -2281,7 +2281,9 @@ void DebuggerClient::loadConfig() { } // make sure file exists - FILE *f = fopen(m_configFileName.c_str(), "a"); + FILE *f = fopen(m_configFileName.c_str(), "r"); + bool needToWriteFile = f == nullptr; + if (needToWriteFile) f = fopen(m_configFileName.c_str(), "a"); if (f) { fclose(f); } else { @@ -2336,7 +2338,9 @@ void DebuggerClient::loadConfig() { m_sourceRoot = m_config["SourceRoot"].getString(); - saveConfig(); // so to generate a starter for people + if (needToWriteFile) { + saveConfig(); // so to generate a starter for people + } } void DebuggerClient::saveConfig() {