Avoid calling get_path() twice inside get_file

Overridden PathDownloadView.get_path() may contain database lookups and logging which should not be called twice if not necessary, as it was in my case.
Because the acquired filename does not change inside get_file(), I replaced the duplicate call.
This commit is contained in:
René Leonhardt 2015-07-14 12:03:52 +02:00
parent 142d8de7fa
commit 75b51ce214

View file

@ -36,4 +36,4 @@ class PathDownloadView(BaseDownloadView):
filename = self.get_path()
if not os.path.isfile(filename):
raise FileNotFound('File "{0}" does not exists'.format(filename))
return File(open(self.get_path(), 'rb'))
return File(open(filename, 'rb'))