Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed May 15, 2018
2 parents cd2f01e + 85c0c96 commit e334afd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
21 changes: 16 additions & 5 deletions common/sql/index/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,16 +747,27 @@ func TestSmallArborescenceWithCache(t *testing.T) {
getDAO(ctxWithCache).Flush(false)

// Then we move a node
path1, _, err := getDAO(ctxWithCache).Path("/test copie", false)
pathFrom, _, err := getDAO(ctxWithCache).Path("/test copie", false)
So(err, ShouldBeNil)
path2, _, err := getDAO(ctxWithCache).Path("/document sans titre/target", true)
pathTo, _, err := getDAO(ctxWithCache).Path("/document sans titre/target", true)
So(err, ShouldBeNil)

// Then we move a node
node1, _ := getDAO(ctxWithCache).GetNode(path1)
node2, _ := getDAO(ctxWithCache).GetNode(path2)
err = getDAO(ctxWithCache).MoveNodeTree(node1, node2)
nodeFrom, _ := getDAO(ctxWithCache).GetNode(pathFrom)
nodeTo, _ := getDAO(ctxWithCache).GetNode(pathTo)

// First of all, we delete the existing node
if nodeTo != nil {
err = getDAO(ctxWithCache).DelNode(nodeTo)
So(err, ShouldBeNil)
}

getDAO(ctxWithCache).Flush(false)

fmt.Println("In here")
err = getDAO(ctxWithCache).MoveNodeTree(nodeFrom, nodeTo)
So(err, ShouldBeNil)
fmt.Println("In there")

getDAO(ctxWithCache).Flush(false)

Expand Down
7 changes: 7 additions & 0 deletions common/sql/index/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,14 @@ func (dao *IndexSQL) MoveNodeTree(nodeFrom *utils.TreeNode, nodeTo *utils.TreeNo

// Updating the original node
update(nodeFrom)

var nodes []*utils.TreeNode

for node := range dao.GetNodeTree(pathFrom) {
nodes = append(nodes, node)
}

for _, node := range nodes {
update(node)
}

Expand Down

0 comments on commit e334afd

Please sign in to comment.