mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-28 11:41:18 +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
|
# get real path for sub repo
|
||||||
real_path = repo.origin_path + path if repo.origin_path else path
|
real_path = repo.origin_path + path if repo.origin_path else path
|
||||||
dirent = seafile_api.get_dirent_by_path(repo.store_id, real_path)
|
dirent = seafile_api.get_dirent_by_path(repo.store_id, real_path)
|
||||||
|
if dirent:
|
||||||
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
||||||
|
else:
|
||||||
|
latest_contributor, last_modified = None, 0
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
latest_contributor, last_modified = None, 0
|
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
|
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,
|
dirent = seafile_api.get_dirent_by_path(sfile.repo.store_id,
|
||||||
real_path)
|
real_path)
|
||||||
|
if dirent:
|
||||||
sfile.last_modified = dirent.mtime
|
sfile.last_modified = dirent.mtime
|
||||||
|
else:
|
||||||
|
sfile.last_modified = 0
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
sfile.last_modified = 0
|
sfile.last_modified = 0
|
||||||
|
@ -1396,7 +1396,10 @@ def group_wiki(request, group, page_name="home"):
|
|||||||
path = '/' + dirent.obj_name
|
path = '/' + dirent.obj_name
|
||||||
try:
|
try:
|
||||||
dirent = seafile_api.get_dirent_by_path(repo.id, path)
|
dirent = seafile_api.get_dirent_by_path(repo.id, path)
|
||||||
|
if dirent:
|
||||||
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
||||||
|
else:
|
||||||
|
latest_contributor, last_modified = None, 0
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
latest_contributor, last_modified = None, 0
|
latest_contributor, last_modified = None, 0
|
||||||
|
@ -15,7 +15,8 @@ def list_dir_by_path(cmmt, path):
|
|||||||
if cmmt.root_id == EMPTY_SHA1:
|
if cmmt.root_id == EMPTY_SHA1:
|
||||||
return []
|
return []
|
||||||
else:
|
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):
|
def get_sub_repo_abbrev_origin_path(repo_name, origin_path):
|
||||||
"""Return abbrev path for sub repo based on `repo_name` and `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:
|
else:
|
||||||
try:
|
try:
|
||||||
dir_id = seafile_api.get_dir_id_by_path(repo.id, path)
|
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,
|
dirs = seafserv_threaded_rpc.list_dir_with_perm(repo.id, path,
|
||||||
dir_id, username,
|
dir_id, username,
|
||||||
offset, limit)
|
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,
|
dirs = seafile_api.list_dir_by_commit_and_path(commit.repo_id,
|
||||||
commit.id, path,
|
commit.id, path,
|
||||||
offset, limit)
|
offset, limit)
|
||||||
|
if not dirs:
|
||||||
|
return ([], [], False)
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
return ([], [], False)
|
return ([], [], False)
|
||||||
|
@ -442,7 +442,10 @@ def _file_view(request, repo_id, path):
|
|||||||
# get real path for sub repo
|
# get real path for sub repo
|
||||||
real_path = repo.origin_path + path if repo.origin_path else path
|
real_path = repo.origin_path + path if repo.origin_path else path
|
||||||
dirent = seafile_api.get_dirent_by_path(repo.store_id, real_path)
|
dirent = seafile_api.get_dirent_by_path(repo.store_id, real_path)
|
||||||
|
if dirent:
|
||||||
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
||||||
|
else:
|
||||||
|
latest_contributor, last_modified = None, 0
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
latest_contributor, last_modified = None, 0
|
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('/'))
|
dirname = os.path.basename(real_path.rstrip('/'))
|
||||||
|
|
||||||
dir_id = seafile_api.get_dir_id_by_path(repo.id, real_path)
|
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:
|
try:
|
||||||
total_size = seaserv.seafserv_threaded_rpc.get_dir_size(
|
total_size = seaserv.seafserv_threaded_rpc.get_dir_size(
|
||||||
|
@ -66,8 +66,12 @@ def personal_wiki(request, page_name="home"):
|
|||||||
path = '/' + dirent.obj_name
|
path = '/' + dirent.obj_name
|
||||||
try:
|
try:
|
||||||
dirent = seafile_api.get_dirent_by_path(repo.id, path)
|
dirent = seafile_api.get_dirent_by_path(repo.id, path)
|
||||||
|
if dirent:
|
||||||
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
latest_contributor, last_modified = dirent.modifier, dirent.mtime
|
||||||
|
else:
|
||||||
|
latest_contributor, last_modified = None, 0
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
|
logger.error(e)
|
||||||
latest_contributor, last_modified = None, 0
|
latest_contributor, last_modified = None, 0
|
||||||
|
|
||||||
wiki_index_exists = True
|
wiki_index_exists = True
|
||||||
|
@ -98,6 +98,8 @@ def get_wiki_pages(repo):
|
|||||||
return pages in hashtable {normalized_name: page_name}
|
return pages in hashtable {normalized_name: page_name}
|
||||||
"""
|
"""
|
||||||
dir_id = seaserv.seafserv_threaded_rpc.get_dir_id_by_path(repo.id, '/')
|
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)
|
dirs = seafile_api.list_dir_by_dir_id(repo.id, dir_id)
|
||||||
pages = {}
|
pages = {}
|
||||||
for e in dirs:
|
for e in dirs:
|
||||||
|
Loading…
Reference in New Issue
Block a user