momo: do not write down manifest if there was no changes (#8120)

This commit is contained in:
Frédéric Péters 2015-08-26 14:02:18 +02:00
parent e9f6936b3a
commit 75dfc039ad
1 changed files with 12 additions and 3 deletions

View File

@ -136,9 +136,18 @@ def generate(request, **kwargs):
'assetsUrl': request.build_absolute_uri(default_storage.url('assets.zip')),
}
fp = default_storage.open('index.json', mode='w')
json.dump(manifest, fp, indent=2)
fp.close()
current_manifest = None
if default_storage.exists('index.json'):
with default_storage.open('index.json', mode='r') as fp:
current_manifest = fp.read()
new_manifest = json.dumps(manifest, indent=2)
if new_manifest != current_manifest:
with default_storage.open('index.json', mode='w') as fp:
fp.write(new_manifest)
else:
messages.info(request, _('No changes were detected.'))
return HttpResponseRedirect(reverse('momo-manager-homepage'))
# assets.zip
if default_storage.exists('assets.zip'):