diff options
Diffstat (limited to 'gluster/swift/common')
-rw-r--r-- | gluster/swift/common/DiskDir.py | 16 | ||||
-rw-r--r-- | gluster/swift/common/constraints.py | 5 | ||||
-rw-r--r-- | gluster/swift/common/utils.py | 6 |
3 files changed, 23 insertions, 4 deletions
diff --git a/gluster/swift/common/DiskDir.py b/gluster/swift/common/DiskDir.py index e8dba35..31b923a 100644 --- a/gluster/swift/common/DiskDir.py +++ b/gluster/swift/common/DiskDir.py @@ -696,7 +696,7 @@ class DiskAccount(DiskCommon): return containers def list_containers_iter(self, limit, marker, end_marker, - prefix, delimiter): + prefix, delimiter, response_content_type=None): """ Return tuple of name, object_count, bytes_used, 0(is_subdir). Used by account server. @@ -709,6 +709,7 @@ class DiskAccount(DiskCommon): if containers: containers.sort() else: + # No containers in account, return empty list return account_list if containers and end_marker: @@ -737,6 +738,19 @@ class DiskAccount(DiskCommon): containers = filter_delimiter(containers, delimiter, prefix, marker) + if response_content_type == 'text/plain': + # The client is only asking for a plain list of containers and NOT + # asking for any extended information about container such as + # bytes used or object count. + for container in containers: + # When response_content_type == 'text/plain', Swift will only + # consume the name of the container (first element of tuple). + # Refer: swift.account.utils.account_listing_response() + account_list.append((container, 0, 0, 0)) + if len(account_list) >= limit: + break + return account_list + count = 0 for cont in containers: list_item = [] diff --git a/gluster/swift/common/constraints.py b/gluster/swift/common/constraints.py index 7979b43..98e2a27 100644 --- a/gluster/swift/common/constraints.py +++ b/gluster/swift/common/constraints.py @@ -97,3 +97,8 @@ __Ring = _ring.Ring # Replace the original Ring class _ring.Ring = ring.Ring + +# Monkey patch account_listing_response +import swift.account.utils +from gluster.swift.account.utils import account_listing_response as gf_als +swift.account.utils.account_listing_response = gf_als diff --git a/gluster/swift/common/utils.py b/gluster/swift/common/utils.py index ded2f0b..8958717 100644 --- a/gluster/swift/common/utils.py +++ b/gluster/swift/common/utils.py @@ -375,7 +375,6 @@ def get_account_details(acc_path): Return container_list and container_count. """ container_list = [] - container_count = 0 if do_isdir(acc_path): for name in do_listdir(acc_path): @@ -383,11 +382,12 @@ def get_account_details(acc_path): or name.lower() == ASYNCDIR \ or name.lower() == TRASHCAN \ or not do_isdir(os.path.join(acc_path, name)): + # Do not include .async_pending, .trashcan and all + # non-directories in containers list continue - container_count += 1 container_list.append(name) - return container_list, container_count + return container_list, len(container_list) def _read_for_etag(fp): |