From 90d80f81e988ba7e6f0dbf78220b5b7cd31a527b Mon Sep 17 00:00:00 2001 From: Stephan Altmueller Date: Fri, 24 Mar 2017 13:19:04 -0400 Subject: Ensure empty output directory to avoid duplicate upload BUG= Change-Id: I491460db0b73e5f6fe0731611400af30e6458537 Reviewed-on: https://pdfium-review.googlesource.com/3121 Reviewed-by: Wei Li Reviewed-by: dsinclair Commit-Queue: dsinclair --- testing/tools/gold.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/testing/tools/gold.py b/testing/tools/gold.py index db3bf81b73..bdae9f4195 100644 --- a/testing/tools/gold.py +++ b/testing/tools/gold.py @@ -56,7 +56,8 @@ class GoldResults(object): """ source_type is the source_type (=corpus) field used for all results. output_dir is the directory where the resulting images are copied and - the dm.json file is written. + the dm.json file is written. If the directory exists it will + be removed and recreated. propertiesStr is a string with space separated key/value pairs that is used to set the top level fields in the output JSON file. keyStr is a string with space separated key/value pairs that @@ -70,9 +71,10 @@ class GoldResults(object): self._results = [] self._outputDir = outputDir - # make sure the output directory exists. - if not os.path.exists(outputDir): - os.makedirs(outputDir) + # make sure the output directory exists and is empty. + if os.path.exists(outputDir): + shutil.rmtree(outputDir, ignore_errors=True) + os.makedirs(outputDir) self._ignore_hashes = set() if ignore_hashes_file: -- cgit v1.2.3