Mercurial > public > sg101
diff downloads/models.py @ 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 | ee87ea74d46b |
children | 3e1905e523be |
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):