=== modified file 'dashboard_app/models.py'
@@ -43,6 +43,7 @@
from django.db.models.signals import post_delete
from django.dispatch import receiver
from django.template import Template, Context
+from django.template.defaultfilters import filesizeformat
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
@@ -543,16 +544,26 @@
self.content.close()
def get_document_format(self):
- self.content.open('rb')
try:
- fmt, doc = DocumentIO.load(self.content)
- return fmt
- finally:
- self.content.close()
+ self.content.open('rb')
+ except IOError:
+ return "unknown"
+ else:
+ try:
+ fmt, doc = DocumentIO.load(self.content)
+ return fmt
+ finally:
+ self.content.close()
def get_serialization_format(self):
return "JSON"
+ def get_content_size(self):
+ try:
+ return filesizeformat(self.content.size)
+ except OSError:
+ return "unknown"
+
class SanitizedBundle(object):
=== modified file 'dashboard_app/templates/dashboard_app/bundle_detail.html'
@@ -44,7 +44,7 @@
<dt>Content SHA1:</dt>
<dd>{{ bundle.content_sha1 }}</dd>
<dt>Content size:</dt>
- <dd>{{ bundle.content.size|filesizeformat }}</dd>
+ <dd>{{ bundle.get_content_size }}</dd>
</dl>
<h3>Storage and format</h3>