momo: don't try to get mtime of assets.zip if it doesn't exist yet (#10579)

This commit is contained in:
Frédéric Péters 2016-04-07 12:17:53 +02:00
parent 41eadbb30f
commit 3b8d489824
1 changed files with 4 additions and 2 deletions

View File

@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import datetime
import json
import shutil
import os
@ -240,14 +241,15 @@ def generate(request, **kwargs):
zf = zipfile.ZipFile(default_storage.open('assets.zip'))
existing_files = set([x for x in zf.namelist() if x[0] != '/' and x[-1] != '/'])
zf.close()
assets_mtime = default_storage.modified_time('assets.zip')
else:
existing_files = set([])
assets_mtime = datetime.datetime(2015, 1, 1)
ckeditor_filenames = set(ckeditor.views.get_image_files())
media_ckeditor_filenames = set(['media/' + x for x in ckeditor_filenames])
if not media_ckeditor_filenames.issubset(existing_files) or (
default_storage.modified_time('assets-base.zip') > default_storage.modified_time('assets.zip')):
if not media_ckeditor_filenames.issubset(existing_files) or default_storage.modified_time('assets-base.zip') > assets_mtime:
# if there are new files, or if the base assets file changed, we
# generate a new assets.zip
shutil.copy(default_storage.path('assets-base.zip'),