Only test once if node type is still the same

This commit is contained in:
Alexander Neumann 2015-01-06 22:09:39 +01:00
parent 248e3218cb
commit 5691d89822
1 changed files with 4 additions and 4 deletions

View File

@ -130,12 +130,12 @@ func (t Tree) CopyFrom(bl *BlobList, other Tree, otherBl *BlobList) error {
// find entry in other tree
oldNode, err := other.Find(node.Name)
// if the node could not be found, proceed to the next
if err == ErrNodeNotFound {
// if the node could not be found or the type has changed, proceed to the next
if err == ErrNodeNotFound || node.Type != oldNode.Type {
continue
}
if node.Type == "file" && oldNode.Type == "file" {
if node.Type == "file" {
// compare content
if node.SameContent(oldNode) {
// copy Content
@ -151,7 +151,7 @@ func (t Tree) CopyFrom(bl *BlobList, other Tree, otherBl *BlobList) error {
bl.Insert(blob)
}
}
} else if node.Type == "dir" && oldNode.Type == "dir" {
} else if node.Type == "dir" {
// fill in all subtrees from old subtree
err := node.tree.CopyFrom(bl, *oldNode.tree, otherBl)
if err != nil {