schema: Introduce schema cache format

Information about schema cache format is stored in every cache item.
When schema cache format changes in incompatible way format will be
increased. When format stored in cache doesn't match currently used
format the entry in cache is ignored.

https://fedorahosted.org/freeipa/ticket/6048

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
David Kupka authored and Jan Cholasta committed 2016-08-03 16:32:39 +02:00
1 parent 29f7f822ab
commit 86977070e1
1 file changed
+10
+10
View File
@@ -23,6 +23,8 @@ from ipapython.dn import DN
from ipapython.dnsutil import DNSName
from ipapython.ipa_log_manager import log_mgr
FORMAT = '0'
if six.PY3:
unicode = str
@@ -478,6 +480,14 @@ class Schema(object):
return _LockedZipFile(path, mode)
def _get_schema_fingerprint(self, schema):
try:
fmt = json.loads(schema.read('format'))
except KeyError:
fmt = '0'
if fmt != FORMAT:
raise RuntimeError('invalid format')
schema_info = json.loads(schema.read(self.schema_info_path))
return schema_info['fingerprint']