]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-shell: Change type of d_name to bytes array 27531/head
authorVarsha Rao <varao@redhat.com>
Thu, 11 Apr 2019 07:07:46 +0000 (12:37 +0530)
committerNathan Cutler <ncutler@suse.com>
Thu, 11 Apr 2019 17:46:19 +0000 (19:46 +0200)
By reverting commit 5106582 'd_name' is always a bytes array. This produces
type error wherever 'd_name' is used with 'str' type. In such cases decode it.

Fixes: https://tracker.ceph.com/issues/39060
Signed-off-by: Varsha Rao <varao@redhat.com>
(cherry picked from commit d0db22a6a51d34433fa4a2d3a423373a5684f75d)

src/tools/cephfs/cephfs-shell

index 88e45f1aacfda420d3bc54c3c0ce0b9cc1934d79..15501474ed1e730171cce46b7ee623d1c9c0c072 100644 (file)
@@ -568,7 +568,7 @@ exists.')
                 items = sorted(list_items(dir_name),
                                key=lambda item: item.d_name)
             if not args.all and len(items) >= 2:
-                items = [i for i in items if not i.d_name.startswith('.')]
+                items = [i for i in items if not i.d_name.decode('utf-8').startswith('.')]
             flag = 0
             if args.S:
                 items = sorted(items, key=lambda item: cephfs.stat(
@@ -578,7 +578,7 @@ exists.')
             for item in items:
                 path = item
                 if not isinstance(item, str):
-                    path = item.d_name
+                    path = item.d_name.decode('utf-8')
                     if item.is_dir():
                         is_dir = True
                     else: