From 3e8d25c9404e8970df411f671f03bb886dcc00bb Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Thu, 19 Apr 2012 10:39:56 -0600 Subject: added fallback for update_media_revision --- askbot/skins/utils.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/askbot/skins/utils.py b/askbot/skins/utils.py index dee14e56..4f8e1992 100644 --- a/askbot/skins/utils.py +++ b/askbot/skins/utils.py @@ -192,7 +192,25 @@ def update_media_revision(skin = None): current_hash = hasher.get_hash_of_dirs(media_dirs) if current_hash != askbot_settings.MEDIA_RESOURCE_REVISION_HASH: - askbot_settings.update('MEDIA_RESOURCE_REVISION', resource_revision + 1) - askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash) + try: + askbot_settings.update('MEDIA_RESOURCE_REVISION', resource_revision + 1) + logging.debug('media revision worked for MEDIA_RESOURCE_REVISION') + except Exception, e: + logging.critical(e.message) + safe_settings_update('MEDIA_RESOURCE_REVISION', resource_revision + 1) + + try: + askbot_settings.update('MEDIA_RESOURCE_REVISION_HASH', current_hash) + logging.debug('media revision worked for MEDIA_RESOURCE_REVISION_HASH') + except Exception, e: + logging.critical(e.message) + safe_settings_update('MEDIA_RESOURCE_REVISION_HASH', current_hash) logging.debug('MEDIA_RESOURCE_REVISION changed') - askbot_settings.MEDIA_RESOURCE_REVISION + + +def safe_settings_update(key, value): + '''Fallback when IntegrityError bug raises''' + from askbot.deps.livesettings.models import Setting + setting = Setting.objects.get(key=key) + setting.value = value + setting.save() -- cgit v1.2.3-1-g7c22