Skip to content
Snippets Groups Projects
Commit 0e111600 authored by Feanil Patel's avatar Feanil Patel
Browse files

Ignore bad cached data.

When migrating from python 2 to 3 we can get in a situation where the
cache has data that the new version of python can't read.  In this case
drop the bad data and re-cache the correct data.
parent 01b6b19f
Branches
Tags
No related merge requests found
......@@ -9,6 +9,7 @@ from django.conf import settings
from django.core.cache import cache
from django.http import HttpResponse
from pytz import UTC
import six
from mobile_api.mobile_platform import MobilePlatform
from mobile_api.models import AppVersionConfig
......@@ -104,13 +105,13 @@ class AppVersionUpgrade(object):
cached_data = cache.get_many([last_supported_date_cache_key, latest_version_cache_key])
last_supported_date = cached_data.get(last_supported_date_cache_key)
if not last_supported_date:
if last_supported_date != self.NO_LAST_SUPPORTED_DATE and not isinstance(last_supported_date, datetime):
last_supported_date = self._get_last_supported_date(platform.NAME, platform.version)
cache.set(last_supported_date_cache_key, last_supported_date, self.CACHE_TIMEOUT)
request_cache_dict[self.LAST_SUPPORTED_DATE_HEADER] = last_supported_date
latest_version = cached_data.get(latest_version_cache_key)
if not latest_version:
if not (latest_version and isinstance(latest_version, six.text_type)):
latest_version = self._get_latest_version(platform.NAME)
cache.set(latest_version_cache_key, latest_version, self.CACHE_TIMEOUT)
request_cache_dict[self.LATEST_VERSION_HEADER] = latest_version
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment