properly rename files by changing file.name and newly registering with parent

This commit is contained in:
Martin Bertschler 2015-11-22 14:34:57 +01:00
parent 3fc0d6fb2b
commit 5a59c3f940
1 changed files with 5 additions and 1 deletions

View File

@ -293,8 +293,12 @@ func (m *MemMapFs) Rename(oldname, newname string) error {
if _, ok := m.getData()[newname]; !ok { if _, ok := m.getData()[newname]; !ok {
m.runlock() m.runlock()
m.lock() m.lock()
m.getData()[newname] = m.getData()[oldname] m.unRegisterWithParent(oldname)
file := m.getData()[oldname].(*InMemoryFile)
delete(m.getData(), oldname) delete(m.getData(), oldname)
file.name = newname
m.getData()[newname] = file
m.registerWithParent(file)
m.unlock() m.unlock()
m.rlock() m.rlock()
} else { } else {