Skip to content

Commit

Permalink
[api] Removed status code and added exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhibhatg committed Mar 1, 2024
1 parent 93d79d9 commit 09d0b49
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/filebrowser/src/filebrowser/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from desktop.lib.i18n import smart_unicode
from desktop.lib.fs.ozone.ofs import get_ofs_home_directory
from desktop.lib.fs.gc.gs import get_gs_home_directory
from hadoop.fs.exceptions import WebHdfsException

from azure.abfs.__init__ import get_home_dir_for_abfs
from aws.s3.s3fs import get_s3_home_directory
Expand Down Expand Up @@ -136,15 +135,20 @@ def rename(request):
@error_handler
def content_summary(request, path):
path = _normalize_path(path)
response = {'summary': None}

if not path:
raise Exception(_('Path parameter is required to fetch content summary'))

if not request.fs.exists(path):
return JsonResponse(response, status=404)

response = {'status': -1, 'summary': None}
try:
stats = request.fs.get_content_summary(path)
replication_factor = request.fs.stats(path)['replication']
stats.summary.update({'replication': replication_factor})
response['status'] = 0
response['summary'] = stats.summary
except WebHdfsException as e:
except Exception as e:
raise Exception(_('Failed to fetch content summary for "%s". ') % path)

return JsonResponse(response)

0 comments on commit 09d0b49

Please sign in to comment.