1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 14:50:29 +00:00

Handle case that get_commits returns empty

This commit is contained in:
zhengxie
2013-04-16 11:32:58 +08:00
parent 20673e5d3d
commit a957a616f6
2 changed files with 6 additions and 3 deletions

View File

@@ -158,10 +158,12 @@ def calculate_repo_last_modify(repo_list):
"""
for repo in repo_list:
repo.latest_modify = get_commits(repo.id, 0, 1)[0].ctime
cmmts = get_commits(repo.id, 0, 1)
repo.latest_modify = cmmts[0].ctime if cmmts else 0
def check_filename_with_rename(repo_id, parent_dir, filename):
latest_commit = get_commits(repo_id, 0, 1)[0]
cmmts = get_commits(repo_id, 0, 1)
latest_commit = cmmts[0] if cmmts else None
if not latest_commit:
return ''
# TODO: what if parrent_dir does not exist?

View File

@@ -760,7 +760,8 @@ def myhome(request):
r.repo_id = r.id
r.repo_name = r.name
r.repo_desc = r.desc
last_commit = get_commits(r_id, 0, 1)[0]
cmmts = get_commits(r_id, 0, 1)
last_commit = cmmts[0] if cmmts else None
r.last_modified = last_commit.ctime if last_commit else 0
r.share_type = 'group'
r.user = get_repo_owner(r_id)