Skip to content

Moving a file in MemoryFS doesn't update its name and causes issues with walk #509

Closed

Description

@althonos

This is on Python 3.10, master branch.

It seems that MemoryFS.move does not update the name of entries being moved, only updating the name in the parent entry (the directory). If an entry is being renamed, this will cause issues for walkers and scandir, but not for listdir.

Steps to reproduce:

import fs
with fs.open_fs("mem://") as mem:
    mem.makedir("foo").writetext("test.txt", "Hello, World")
    mem.move("foo/test.txt", "foo/test2.txt")
    print(mem.listdir("/foo"))
    mem.tree()

Expected output:

['test2.txt']
└── foo
    └── test2.txt

Actual output:

['test2.txt']
└── foo
    └── test.txt

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions