From cf9613f166a2f3a7a6a52cff8ae5282aac45f3d9 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Wed, 20 Mar 2019 03:57:35 +0000 Subject: [PATCH] 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/+/1522291 Reviewed-by: Takuto Ikuta Reviewed-by: Fumitoshi Ukai Commit-Queue: Bruce Dawson --- ninjalog_uploader_wrapper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ninjalog_uploader_wrapper.py b/ninjalog_uploader_wrapper.py index ec7487e5a..5eb712efa 100755 --- a/ninjalog_uploader_wrapper.py +++ b/ninjalog_uploader_wrapper.py @@ -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: