Merge pull request #1994 from normanjaeckel/FileNotFound
Fixed error if a PDF file was deleted from the server. Fixed #1988.
This commit is contained in:
commit
ca5f707f74
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user