Commit cf9613f1 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Avoiding writing ninjalog.cfg unnecessarily

Writing to ninjalog.cfg comes with the risk of failure (Ctrl+C at the
wrong time) which can lead to an empty or corrupted file. This will
cause errors on subsequent builds when loading the config file, and
will lose the users opt-in/out settings.

This change ensures that the config file is only written when something
has changed, thus essentially avoiding the risk.

Bug: 941810
Change-Id: If266f07536569c9ac91ee37c28797c8b2ccc6fdc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1522291Reviewed-by: 's avatarTakuto Ikuta <tikuta@chromium.org>
Reviewed-by: 's avatarFumitoshi Ukai <ukai@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
parent 8e85c22d
......@@ -86,8 +86,6 @@ def main():
print('ninjalog upload is opted out.')
return 0
SaveConfig(config)
if 'opt-in' in config and not config['opt-in']:
# Upload is opted out.
return 0
......@@ -99,6 +97,8 @@ def main():
if config.get("countdown", 0) > 0:
# Need to show message.
ShowMessage(config["countdown"])
# Only save config if something has meaningfully changed.
SaveConfig(config)
return 0
if len(sys.argv) == 1:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment