Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #7160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

update #7160

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions seahub/seadoc/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
normalize_dir_path, PREVIEW_FILEEXT, \
gen_inner_file_get_url, gen_inner_file_upload_url, gen_file_get_url, \
get_service_url, is_valid_username, is_pro_version, \
get_file_history_by_day, get_file_daily_history_detail, HAS_FILE_SEARCH, HAS_FILE_SEASEARCH, gen_file_upload_url
get_file_history_by_day, get_file_daily_history_detail, HAS_FILE_SEARCH, HAS_FILE_SEASEARCH, gen_file_upload_url, \
get_non_sdoc_file_exts
from seahub.tags.models import FileUUIDMap
from seahub.utils.error_msg import file_type_error_msg
from seahub.utils.repo import parse_repo_perm, get_related_users_by_repo
Expand Down Expand Up @@ -2918,7 +2919,16 @@ def get(self, request, file_uuid):
except ValueError:
current_page = 1
per_page = 10

search_type = request.GET.get('search_type', None)
suffixes = []
if search_type == 'sdoc':
suffixes = ['sdoc',]
if search_type == 'file':
suffixes = get_non_sdoc_file_exts
if not suffixes:
error_msg = 'search_type is not valid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

# resource check
uuid_map = FileUUIDMap.objects.get_fileuuidmap_by_uuid(file_uuid)
if not uuid_map:
Expand All @@ -2928,7 +2938,7 @@ def get(self, request, file_uuid):
repo = seafile_api.get_repo(repo_id)

search_filename_only = True
suffixes = ['sdoc',]

if HAS_FILE_SEARCH:
org_id = get_org_id_by_repo_id(repo_id)
map_id = repo.origin_repo_id if repo.origin_repo_id else repo_id
Expand Down
8 changes: 8 additions & 0 deletions seahub/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ def is_db_sqlite3():
SEADOC: ('sdoc',),
}

def get_non_sdoc_file_exts():
exts = []
for filetype in PREVIEW_FILEEXT.keys():
if filetype in [IMAGE, SEADOC]:
continue
exts.extend(list(PREVIEW_FILEEXT.get(filetype, [])))
return exts

def gen_fileext_type_map():
"""
Generate previewed file extension and file type relation map.
Expand Down
Loading