memfs: fix Rename from root to dir
diff --git a/memfs/storage.go b/memfs/storage.go
index 6ee157a..03e39c3 100644
--- a/memfs/storage.go
+++ b/memfs/storage.go
@@ -126,15 +126,25 @@
 		from := ops[0]
 		to := ops[1]
 
-		s.files[to] = s.files[from]
-		s.children[to] = s.children[from]
-		delete(s.children, from)
-		delete(s.files, from)
+		if err := s.move(from, to); err != nil {
+			return err
+		}
 	}
 
 	return nil
 }
 
+func (s *storage) move(from, to string) error {
+	s.files[to] = s.files[from]
+	s.files[to].BaseFilename = filepath.Base(to)
+	s.children[to] = s.children[from]
+
+	delete(s.children, from)
+	delete(s.files, from)
+
+	return s.createParent(to, 0644, s.files[to])
+}
+
 func (s *storage) Remove(path string) error {
 	path = filepath.Clean(path)