Fixed error if a PDF file was deleted from the server. Fixed #1988.

This commit is contained in:
Norman Jäckel 2016-02-23 22:34:50 +01:00
parent 4016c1ea4b
commit e8402f6ffa

View File

@ -24,7 +24,11 @@ class AngularCompatibleFileField(FileField):
'type': filetype
}
if filetype == 'application/pdf':
result['pages'] = PdfFileReader(open(value.path, 'rb')).getNumPages()
try:
result['pages'] = PdfFileReader(open(value.path, 'rb')).getNumPages()
except FileNotFoundError:
# File was deleted from server. Set 'pages' to 0.
result['pages'] = 0
return result