Skip to content

Commit 13f1c29

Browse files
committed
Fix MemoryFS entries not being renamed when moved
1 parent fee7ee6 commit 13f1c29

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/memoryfs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,11 @@ def move(self, src_path, dst_path, overwrite=False, preserve_time=False):
463463
elif not overwrite and dst_name in dst_dir_entry:
464464
raise errors.DestinationExists(dst_path)
465465

466+
# move the entry from the src folder to the dst folder
466467
dst_dir_entry.set_entry(dst_name, src_entry)
467468
src_dir_entry.remove_entry(src_name)
469+
# make sure to update the entry name itself (see #509)
470+
src_entry.name = dst_name
468471

469472
if preserve_time:
470473
copy_modified_time(self, src_path, self, dst_path)
@@ -481,12 +484,16 @@ def movedir(self, src_path, dst_path, create=False, preserve_time=False):
481484
if not src_entry.is_dir:
482485
raise errors.DirectoryExpected(src_path)
483486

487+
# move the entry from the src folder to the dst folder
484488
dst_dir_entry = self._get_dir_entry(dst_dir)
485489
if dst_dir_entry is None or (not create and dst_name not in dst_dir_entry):
486490
raise errors.ResourceNotFound(dst_path)
487491

492+
# move the entry from the src folder to the dst folder
488493
dst_dir_entry.set_entry(dst_name, src_entry)
489494
src_dir_entry.remove_entry(src_name)
495+
# make sure to update the entry name itself (see #509)
496+
src_entry.name = dst_name
490497

491498
if preserve_time:
492499
copy_modified_time(self, src_path, self, dst_path)

0 commit comments

Comments
 (0)