From c1e2348695e4cd3c9760bff49e48c433f4512afb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 18 May 2014 23:42:47 +0800 Subject: [PATCH] Check for version when downloading external binaries. --- .gitignore | 2 +- script/update-external-binaries.py | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index c9a7fece9aa3..1907e665442e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .DS_Store /build/ /dist/ -/frameworks/ +/external_binaries/ /out/ /vendor/brightray/vendor/download/ /vendor/python_26/ diff --git a/script/update-external-binaries.py b/script/update-external-binaries.py index c8045c28cad0..5d8014f55c13 100755 --- a/script/update-external-binaries.py +++ b/script/update-external-binaries.py @@ -7,20 +7,22 @@ import os from lib.util import safe_mkdir, extract_zip, tempdir, download +VERSION = 'v0.0.3' SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) FRAMEWORKS_URL = 'https://github.com/atom/atom-shell-frameworks/releases' \ - '/download/v0.0.3' + '/download/' + VERSION def main(): os.chdir(SOURCE_ROOT) - try: - os.makedirs('external_binaries') - except OSError as e: - if e.errno != errno.EEXIST: - raise - else: - return + version_file = os.path.join(SOURCE_ROOT, 'external_binaries', '.version') + + safe_mkdir('external_binaries') + if (is_updated(version_file, VERSION)): + return + + with open(version_file, 'w') as f: + f.write(VERSION) if sys.platform == 'darwin': download_and_unzip('Mantle') @@ -30,6 +32,17 @@ def main(): download_and_unzip('directxsdk') +def is_updated(version_file, version): + existing_version = '' + try: + with open(version_file, 'r') as f: + existing_version = f.readline().strip() + except IOError as e: + if e.errno != errno.ENOENT: + raise + return existing_version == version + + def download_and_unzip(framework): zip_path = download_framework(framework) if zip_path: