[damned-lies] Check for file existence in vertimus diff view
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Check for file existence in vertimus diff view
- Date: Wed, 15 Aug 2012 07:06:36 +0000 (UTC)
commit a9a5e2d5f1ec645b615152150a1ab4a41db3f479
Author: Claude Paroz <claude 2xlibre net>
Date: Wed Aug 15 09:05:55 2012 +0200
Check for file existence in vertimus diff view
vertimus/views.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/vertimus/views.py b/vertimus/views.py
index 7c01614..5b4b0bb 100644
--- a/vertimus/views.py
+++ b/vertimus/views.py
@@ -19,6 +19,8 @@
# along with Damned Lies; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import os
+
from django.conf import settings
from django.core import urlresolvers
from django.http import HttpResponseRedirect, Http404
@@ -150,6 +152,8 @@ def vertimus_diff(request, action_id_1, action_id_2, level):
file_path_1 = action_1.merged_file and action_1.merged_file.path or action_1.file.path
reduced = is_po_reduced(file_path_1)
+ if not os.path.exists(file_path_1):
+ raise Http404("File not found")
try:
content_1 = [l.decode('utf-8') for l in open(file_path_1, 'U').readlines()]
@@ -183,6 +187,8 @@ def vertimus_diff(request, action_id_1, action_id_2, level):
stats = get_object_or_404(Statistics, branch=state.branch, domain=state.domain, language=None)
descr_2 = _("Latest POT file")
file_path_2 = stats.po_path(reduced=reduced)
+ if not os.path.exists(file_path_2):
+ raise Http404("File not found")
try:
content_2 = [l.decode('utf-8') for l in open(file_path_2, 'U').readlines()]
except UnicodeDecodeError:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]