Skip to content

Commit f51d364

Browse files
committed
Use os.renames in DirectoryStore's rename
Instead of using `os.rename` and creating missing directories before when renaming content in a `DirectoryStore`, just use `os.rename` to handle this move for us. This will automatically create missing directories for us in the destination path so we don't have to. Also it prunes away any empty directories in the old path, which we were not doing before. IOW this fixes a bug as well.
1 parent d94256d commit f51d364

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

zarr/storage.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,7 @@ def rename(self, src_path, dst_path):
841841
src_path = os.path.join(dir_path, store_src_path)
842842
dst_path = os.path.join(dir_path, store_dst_path)
843843

844-
dst_dir = os.path.dirname(dst_path)
845-
if not os.path.exists(dst_dir):
846-
os.makedirs(dst_dir)
847-
os.rename(src_path, dst_path)
844+
os.renames(src_path, dst_path)
848845

849846
def rmdir(self, path=None):
850847
store_path = normalize_storage_path(path)

0 commit comments

Comments
 (0)