Skip to content

Commit

Permalink
Merge pull request #13 from evan-gu/fileSystem
Browse files Browse the repository at this point in the history
fix bug of deleting the root
  • Loading branch information
xiang90 committed Sep 15, 2013
2 parents e41ef9b + cd6ed3d commit 36329e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions file_system/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (n *Node) Remove(recursive bool, callback func(path string)) error {
if !n.IsDir() { // file node: key-value pair
_, 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
// Handled by garbage collector
delete(n.Parent.Children, name)
Expand All @@ -102,7 +102,7 @@ func (n *Node) Remove(recursive bool, callback func(path string)) error {

// delete self
_, 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)

if callback != nil {
Expand Down

0 comments on commit 36329e9

Please sign in to comment.