mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-27 11:10:10 +00:00
Fix dir/file api path not exists error
This commit is contained in:
parent
0f65ddfae5
commit
61dff076d4
@ -1852,7 +1852,10 @@ class FileDetailView(APIView):
|
||||
# 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)
|
||||
if dirent:
|
||||
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
||||
else:
|
||||
latest_contributor, last_modified = None, 0
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
latest_contributor, last_modified = None, 0
|
||||
|
@ -120,7 +120,10 @@ class UserStarredFilesManager(models.Manager):
|
||||
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)
|
||||
if dirent:
|
||||
sfile.last_modified = dirent.mtime
|
||||
else:
|
||||
sfile.last_modified = 0
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
sfile.last_modified = 0
|
||||
|
@ -1396,7 +1396,10 @@ def group_wiki(request, group, page_name="home"):
|
||||
path = '/' + dirent.obj_name
|
||||
try:
|
||||
dirent = seafile_api.get_dirent_by_path(repo.id, path)
|
||||
if dirent:
|
||||
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
||||
else:
|
||||
latest_contributor, last_modified = None, 0
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
latest_contributor, last_modified = None, 0
|
||||
|
@ -15,7 +15,8 @@ def list_dir_by_path(cmmt, path):
|
||||
if cmmt.root_id == EMPTY_SHA1:
|
||||
return []
|
||||
else:
|
||||
return seafile_api.list_dir_by_commit_and_path(cmmt.repo_id, cmmt.id, path)
|
||||
dirs = seafile_api.list_dir_by_commit_and_path(cmmt.repo_id, cmmt.id, path)
|
||||
return dirs if dirs else []
|
||||
|
||||
def get_sub_repo_abbrev_origin_path(repo_name, origin_path):
|
||||
"""Return abbrev path for sub repo based on `repo_name` and `origin_path`.
|
||||
|
@ -202,6 +202,8 @@ def get_repo_dirents_with_perm(request, repo, commit, path, offset=-1, limit=-1)
|
||||
else:
|
||||
try:
|
||||
dir_id = seafile_api.get_dir_id_by_path(repo.id, path)
|
||||
if not dir_id:
|
||||
return ([], [], False)
|
||||
dirs = seafserv_threaded_rpc.list_dir_with_perm(repo.id, path,
|
||||
dir_id, username,
|
||||
offset, limit)
|
||||
@ -285,6 +287,8 @@ def get_repo_dirents(request, repo, commit, path, offset=-1, limit=-1):
|
||||
dirs = seafile_api.list_dir_by_commit_and_path(commit.repo_id,
|
||||
commit.id, path,
|
||||
offset, limit)
|
||||
if not dirs:
|
||||
return ([], [], False)
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
return ([], [], False)
|
||||
|
@ -442,7 +442,10 @@ def _file_view(request, 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)
|
||||
if dirent:
|
||||
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
||||
else:
|
||||
latest_contributor, last_modified = None, 0
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
latest_contributor, last_modified = None, 0
|
||||
|
@ -374,6 +374,9 @@ def _download_dir_from_share_link(request, fileshare, repo, real_path):
|
||||
dirname = os.path.basename(real_path.rstrip('/'))
|
||||
|
||||
dir_id = seafile_api.get_dir_id_by_path(repo.id, real_path)
|
||||
if not dir_id:
|
||||
return render_error(
|
||||
request, _(u'Unable to download: folder not found.'))
|
||||
|
||||
try:
|
||||
total_size = seaserv.seafserv_threaded_rpc.get_dir_size(
|
||||
|
@ -66,8 +66,12 @@ def personal_wiki(request, page_name="home"):
|
||||
path = '/' + dirent.obj_name
|
||||
try:
|
||||
dirent = seafile_api.get_dirent_by_path(repo.id, path)
|
||||
if dirent:
|
||||
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
||||
else:
|
||||
latest_contributor, last_modified = None, 0
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
latest_contributor, last_modified = None, 0
|
||||
|
||||
wiki_index_exists = True
|
||||
|
@ -98,6 +98,8 @@ def get_wiki_pages(repo):
|
||||
return pages in hashtable {normalized_name: page_name}
|
||||
"""
|
||||
dir_id = seaserv.seafserv_threaded_rpc.get_dir_id_by_path(repo.id, '/')
|
||||
if not dir_id:
|
||||
return {}
|
||||
dirs = seafile_api.list_dir_by_dir_id(repo.id, dir_id)
|
||||
pages = {}
|
||||
for e in dirs:
|
||||
|
Loading…
Reference in New Issue
Block a user