From 2090c13e945e6f1715e87e608f87480b5be4d72e Mon Sep 17 00:00:00 2001 From: zhengxie Date: Tue, 3 Feb 2015 17:17:36 +0800 Subject: [PATCH] Fix file last update time in sub repo --- seahub/base/models.py | 7 ++++--- seahub/utils/repo.py | 1 - seahub/views/file.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/seahub/base/models.py b/seahub/base/models.py index 0ff280efa8..afe1e5ac7c 100644 --- a/seahub/base/models.py +++ b/seahub/base/models.py @@ -116,8 +116,10 @@ class UserStarredFilesManager(models.Manager): continue try: - dirent = seafile_api.get_dirent_by_path(sfile.repo.id, - sfile.path) + # get real path for sub repo + real_path = sfile.repo.origin_path + sfile.path if sfile.repo.origin_path else sfile.path + dirent = seafile_api.get_dirent_by_path(sfile.repo.store_id, + real_path) sfile.last_modified = dirent.mtime except SearpcError as e: logger.error(e) @@ -207,4 +209,3 @@ class DeviceToken(models.Model): def __unicode__(self): return "/".join(self.user, self.token) - diff --git a/seahub/utils/repo.py b/seahub/utils/repo.py index cb29771194..ad8a6bf5fd 100644 --- a/seahub/utils/repo.py +++ b/seahub/utils/repo.py @@ -7,4 +7,3 @@ def list_dir_by_path(cmmt, path): return [] else: return seafile_api.list_dir_by_commit_and_path(cmmt.repo_id, cmmt.id, path) - diff --git a/seahub/views/file.py b/seahub/views/file.py index 8312567856..690e90bdad 100644 --- a/seahub/views/file.py +++ b/seahub/views/file.py @@ -58,7 +58,6 @@ from seahub.utils.file_types import (IMAGE, PDF, DOCUMENT, SPREADSHEET, MARKDOWN, TEXT, SF, OPENDOCUMENT) from seahub.utils.star import is_file_starred from seahub.utils import HAS_OFFICE_CONVERTER, FILEEXT_TYPE_MAP - if HAS_OFFICE_CONVERTER: from seahub.utils import ( query_office_convert_status, query_office_file_pages, add_office_convert_task, @@ -436,7 +435,9 @@ def view_file(request, repo_id): # fetch file contributors and latest contributor try: - dirent = seafile_api.get_dirent_by_path(repo.id, path) + # get real path for sub repo + real_path = repo.origin_path + path if repo.origin_path else path + dirent = seafile_api.get_dirent_by_path(repo.store_id, real_path) latest_contributor, last_modified = dirent.modifier, dirent.mtime except SearpcError as e: logger.error(e)