assets manager: consider missing files as empty (#35397)

This commit is contained in:
Thomas NOËL 2019-08-14 11:50:19 +02:00
parent 9ec36e807d
commit 073520e111
2 changed files with 9 additions and 1 deletions

View File

@ -80,7 +80,10 @@ class SlotAsset(object):
def size(self):
if self.asset:
return os.stat(self.asset.asset.path).st_size
try:
return os.stat(self.asset.asset.path).st_size
except OSError:
pass
return None
def src(self):

View File

@ -867,6 +867,11 @@ def test_asset_slots_management(app, admin_user):
assert '>Delete<' in resp.text
assert Asset.objects.filter(key='collectivity:cgu').count() == 1
# badly remove the file, manager page is still visible
os.unlink(Asset.objects.filter(key='collectivity:cgu')[0].asset.path)
resp = app.get('/manage/assets/')
assert '>CGU<' in resp.text
def test_asset_export_import(app, admin_user):
for path in ('uploads', 'assets', 'cache'):