Verified Commit 47d7a884 authored by Huste, Tobias's avatar Huste, Tobias
Browse files

browsing: make number of maximum directories configurable

- maximum number of directories can now be listed via query parameter
parent e34dad80
Pipeline #2655 passed with stage
in 9 minutes and 21 seconds
......@@ -160,12 +160,16 @@ class SFTPBrowserAPI(ContentNegotiatedMethodView):
validate=path_validator,
missing='/',
),
'max': fields.Integer(
location='query',
missing='10000',
)
}
@use_kwargs(post_args)
@need_authentication
@cached(timeout=300, key_prefix=make_key, query_string=False)
def post(self, remote_server, path='/'):
def post(self, remote_server, path='/', max=10000):
"""
Return list of directories and files.
......@@ -214,7 +218,7 @@ class SFTPBrowserAPI(ContentNegotiatedMethodView):
isdir=True,
endpoint=endpoint,
)]
for element in sftp.listdir_iter(path):
for element in limit(sftp.listdir_iter(path), limit=max):
# get file size
full_path = os.path.join(path, element.filename)
endpoint = base_url + urlencode({'path': full_path})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment