From c916aa4266c196acd117f1b7eac396789a427e68 Mon Sep 17 00:00:00 2001 From: lins05 Date: Wed, 31 Oct 2012 15:11:40 +0800 Subject: [PATCH] fixed a bug in file contributors --- utils.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index feba51308f..bfe9490efa 100644 --- a/utils.py +++ b/utils.py @@ -377,8 +377,17 @@ def get_file_contributors(repo_id, file_path, file_path_hash, file_id): contributors = [] last_modified = 0 try: - fc = FileContributors.objects.get(repo_id=repo_id, - file_path_hash=file_path_hash) + # HACK: Fixed the unique key bug in 1.1 + # Should be removed in future + fc = FileContributors.objects.filter(repo_id=repo_id, + file_path_hash=file_path_hash) + if not fc: + raise FileContributors.DoesNotExist + else: + if len(fc) > 1: + for e in fc[1:]: + e.delete() + fc = fc[0] except FileContributors.DoesNotExist: # has no cache yet contributors, last_modified = get_file_contributors_from_revisions (repo_id, file_path)