From 75b51ce214d49b68babdf12e2297a38dee1f31ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Leonhardt?= Date: Tue, 14 Jul 2015 12:03:52 +0200 Subject: [PATCH] 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. --- django_downloadview/views/path.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_downloadview/views/path.py b/django_downloadview/views/path.py index 2a5d09d..2779ddf 100644 --- a/django_downloadview/views/path.py +++ b/django_downloadview/views/path.py @@ -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'))