Fixed error if a PDF file was deleted from the server. Fixed #1988.
This commit is contained in:
parent
4016c1ea4b
commit
e8402f6ffa
@ -24,7 +24,11 @@ class AngularCompatibleFileField(FileField):
|
||||
'type': filetype
|
||||
}
|
||||
if filetype == 'application/pdf':
|
||||
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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user