File tree 2 files changed +40
-0
lines changed
utils/merkletrie/filesystem
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ func (n *node) NumChildren() (int, error) {
77
77
}
78
78
79
79
func (n * node ) calculateChildren () error {
80
+ if ! n .IsDir () {
81
+ return nil
82
+ }
83
+
80
84
if len (n .children ) != 0 {
81
85
return nil
82
86
}
Original file line number Diff line number Diff line change @@ -82,6 +82,42 @@ func (s *NoderSuite) TestDiffChangeContent(c *C) {
82
82
c .Assert (ch , HasLen , 1 )
83
83
}
84
84
85
+ func (s * NoderSuite ) TestDiffSymlinkDirOnA (c * C ) {
86
+ fsA := memfs .New ()
87
+ WriteFile (fsA , "qux/qux" , []byte ("foo" ), 0644 )
88
+
89
+ fsB := memfs .New ()
90
+ fsB .Symlink ("qux" , "foo" )
91
+ WriteFile (fsB , "qux/qux" , []byte ("foo" ), 0644 )
92
+
93
+ ch , err := merkletrie .DiffTree (
94
+ NewRootNode (fsA , nil ),
95
+ NewRootNode (fsB , nil ),
96
+ IsEquals ,
97
+ )
98
+
99
+ c .Assert (err , IsNil )
100
+ c .Assert (ch , HasLen , 1 )
101
+ }
102
+
103
+ func (s * NoderSuite ) TestDiffSymlinkDirOnB (c * C ) {
104
+ fsA := memfs .New ()
105
+ fsA .Symlink ("qux" , "foo" )
106
+ WriteFile (fsA , "qux/qux" , []byte ("foo" ), 0644 )
107
+
108
+ fsB := memfs .New ()
109
+ WriteFile (fsB , "qux/qux" , []byte ("foo" ), 0644 )
110
+
111
+ ch , err := merkletrie .DiffTree (
112
+ NewRootNode (fsA , nil ),
113
+ NewRootNode (fsB , nil ),
114
+ IsEquals ,
115
+ )
116
+
117
+ c .Assert (err , IsNil )
118
+ c .Assert (ch , HasLen , 1 )
119
+ }
120
+
85
121
func (s * NoderSuite ) TestDiffChangeMissing (c * C ) {
86
122
fsA := memfs .New ()
87
123
WriteFile (fsA , "foo" , []byte ("foo" ), 0644 )
You can’t perform that action at this time.
0 commit comments