From 5a59c3f940aafbdc494834f1ce72b6cc59e6bc20 Mon Sep 17 00:00:00 2001 From: Martin Bertschler Date: Sun, 22 Nov 2015 14:34:57 +0100 Subject: [PATCH] properly rename files by changing file.name and newly registering with parent --- memmap.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/memmap.go b/memmap.go index 8a0e3be..3bf85f7 100644 --- a/memmap.go +++ b/memmap.go @@ -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 {