From 0ff98f616b5dce77d5e5d8ba9882f30dc02a34e4 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 5 Aug 2014 11:51:17 +0200 Subject: [PATCH] only update new modules --- oml/update.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/oml/update.py b/oml/update.py index 9f58628..38cb268 100644 --- a/oml/update.py +++ b/oml/update.py @@ -63,18 +63,19 @@ def update(): fd.write(release_data) os.chdir(settings.base_dir) for module in release['modules']: - package_tar = os.path.join(settings.updates_path, release['modules'][module]['name']) - url = RELEASE_URL.replace('release.json', package_tar) - download(url, package_tar) - if ox.sha1sum(package_tar) == release['modules'][module]['sha1']: - shutil.move(module, '%s_old' % module) - tar = tarfile.open(package_tar) - tar.extractall() - tar.close() - shutil.rmtree('%s_old' % module) - else: - return False - os.unlink(package_tar) + if release['modules'][module]['version'] > settings.release['modules'][module]['version']: + package_tar = os.path.join(settings.updates_path, release['modules'][module]['name']) + url = RELEASE_URL.replace('release.json', package_tar) + download(url, package_tar) + if ox.sha1sum(package_tar) == release['modules'][module]['sha1']: + shutil.move(module, '%s_old' % module) + tar = tarfile.open(package_tar) + tar.extractall() + tar.close() + shutil.rmtree('%s_old' % module) + else: + return False + os.unlink(package_tar) with open(os.path.join(settings.config_dir, 'release.json'), 'w') as fd: fd.write(release_data) cmd = ['./ctl', 'stop']