|
@@ -76,7 +76,7 @@ func (n *Node) Remove(recursive bool, callback func(path string)) error {
|
|
|
if !n.IsDir() { // file node: key-value pair
|
|
if !n.IsDir() { // file node: key-value pair
|
|
|
_, name := path.Split(n.Path)
|
|
_, name := path.Split(n.Path)
|
|
|
|
|
|
|
|
- if n.Parent.Children[name] == n {
|
|
|
|
|
|
|
+ if n.Parent != nil && n.Parent.Children[name] == n {
|
|
|
// This is the only pointer to Node object
|
|
// This is the only pointer to Node object
|
|
|
// Handled by garbage collector
|
|
// Handled by garbage collector
|
|
|
delete(n.Parent.Children, name)
|
|
delete(n.Parent.Children, name)
|
|
@@ -102,7 +102,7 @@ func (n *Node) Remove(recursive bool, callback func(path string)) error {
|
|
|
|
|
|
|
|
// delete self
|
|
// delete self
|
|
|
_, name := path.Split(n.Path)
|
|
_, name := path.Split(n.Path)
|
|
|
- if n.Parent.Children[name] == n {
|
|
|
|
|
|
|
+ if n.Parent != nil && n.Parent.Children[name] == n {
|
|
|
delete(n.Parent.Children, name)
|
|
delete(n.Parent.Children, name)
|
|
|
|
|
|
|
|
if callback != nil {
|
|
if callback != nil {
|