changeset 661:15dbe0ccda95

Prevent exceptions when viewing downloads in the admin when the file doesn't exist on the filesystem. This is usually seen in development but can also happen in production if the file is missing.
author Brian Neal <bgneal@gmail.com>
date Tue, 14 May 2013 21:02:47 -0500
parents 0dd84cff2477
children b347a31d12dd
files downloads/models.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/downloads/models.py	Tue May 14 21:01:40 2013 -0500
+++ b/downloads/models.py	Tue May 14 21:02:47 2013 -0500
@@ -64,7 +64,10 @@
         abstract = True
 
     def size(self):
-        return filesizeformat(self.file.size)
+        try:
+            return filesizeformat(self.file.size)
+        except OSError:
+            return '?'
 
 
 class PendingDownload(DownloadBase):