Эх сурвалжийг харах

[raz] Skip checking parent path stats when RAZ is enabled (#3009)

Harsh Gupta 3 жил өмнө
parent
commit
cf3ebf8b3b

+ 11 - 10
apps/filebrowser/src/filebrowser/views.py

@@ -47,6 +47,7 @@ from django.utils.html import escape
 from aws.s3.s3fs import S3FileSystemException, S3ListAllBucketsException, get_s3_home_directory
 from desktop import appmanager
 from desktop.auth.backend import is_admin
+from desktop.conf import RAZ
 from desktop.lib import fsmanager
 from desktop.lib import i18n
 from desktop.lib.conf import coerce_bool
@@ -549,8 +550,16 @@ def listdir_paged(request, path):
     page = None
     shown_stats = []
 
-  # Include parent dir always as second option, unless at filesystem root.
-  if not request.fs.isroot(path):
+  # Include same dir always as first option to see stats of the current folder.
+  current_stat = request.fs.stats(path)
+  # The 'path' field would be absolute, but we want its basename to be
+  # actually '.' for display purposes. Encode it since _massage_stats expects byte strings.
+  current_stat.path = path
+  current_stat.name = "."
+  shown_stats.insert(0, current_stat)
+
+  # Include parent dir always as second option, unless at filesystem root or when RAZ is enabled.
+  if not (request.fs.isroot(path) or RAZ.IS_ENABLED.get()):
     parent_path = request.fs.parent_path(path)
     parent_stat = request.fs.stats(parent_path)
     # The 'path' field would be absolute, but we want its basename to be
@@ -559,14 +568,6 @@ def listdir_paged(request, path):
     parent_stat['name'] = ".."
     shown_stats.insert(0, parent_stat)
 
-  # Include same dir always as first option to see stats of the current folder
-  current_stat = request.fs.stats(path)
-  # The 'path' field would be absolute, but we want its basename to be
-  # actually '.' for display purposes. Encode it since _massage_stats expects byte strings.
-  current_stat.path = path
-  current_stat.name = "."
-  shown_stats.insert(1, current_stat)
-
   if page:
     page.object_list = [_massage_stats(request, stat_absolute_path(path, s)) for s in shown_stats]