|
37 | 37 | normalize_storage_path, buffer_size,
|
38 | 38 | normalize_fill_value, nolock, normalize_dtype)
|
39 | 39 | from zarr.meta import encode_array_metadata, encode_group_metadata
|
40 |
| -from zarr.compat import PY2, MutableMapping, OrderedDict_move_to_end |
| 40 | +from zarr.compat import PY2, MutableMapping, OrderedDict_move_to_end, scandir |
41 | 41 | from numcodecs.registry import codec_registry
|
42 | 42 | from numcodecs.compat import ensure_bytes, ensure_contiguous_ndarray
|
43 | 43 | from zarr.errors import (err_contains_group, err_contains_array, err_bad_compressor,
|
@@ -846,12 +846,10 @@ def getsize(self, path=None):
|
846 | 846 | if os.path.isfile(fs_path):
|
847 | 847 | return os.path.getsize(fs_path)
|
848 | 848 | elif os.path.isdir(fs_path):
|
849 |
| - children = os.listdir(fs_path) |
850 | 849 | size = 0
|
851 |
| - for child in children: |
852 |
| - child_fs_path = os.path.join(fs_path, child) |
853 |
| - if os.path.isfile(child_fs_path): |
854 |
| - size += os.path.getsize(child_fs_path) |
| 850 | + for child in scandir(fs_path): |
| 851 | + if child.is_file(): |
| 852 | + size += child.stat().st_size |
855 | 853 | return size
|
856 | 854 | else:
|
857 | 855 | return 0
|
|
0 commit comments