forked from mirror/afero
properly rename files by changing file.name and newly registering with parent
This commit is contained in:
parent
3fc0d6fb2b
commit
5a59c3f940
|
@ -293,8 +293,12 @@ func (m *MemMapFs) Rename(oldname, newname string) error {
|
|||
if _, ok := m.getData()[newname]; !ok {
|
||||
m.runlock()
|
||||
m.lock()
|
||||
m.getData()[newname] = m.getData()[oldname]
|
||||
m.unRegisterWithParent(oldname)
|
||||
file := m.getData()[oldname].(*InMemoryFile)
|
||||
delete(m.getData(), oldname)
|
||||
file.name = newname
|
||||
m.getData()[newname] = file
|
||||
m.registerWithParent(file)
|
||||
m.unlock()
|
||||
m.rlock()
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue