@@ -126,7 +126,7 @@ describe('Box', () => {
126
126
} ) . finally ( ( ) => fs . rmdir ( box . base ) ) ;
127
127
} ) ;
128
128
129
- it ( 'process() - mtime changed' , ( ) => {
129
+ it ( 'process() - update ( mtime changed and hash changed) ' , ( ) => {
130
130
const box = newBox ( 'test' ) ;
131
131
const name = 'a.txt' ;
132
132
const path = pathFn . join ( box . base , name ) ;
@@ -139,7 +139,8 @@ describe('Box', () => {
139
139
fs . writeFile ( path , 'a' ) ,
140
140
box . Cache . insert ( {
141
141
_id : cacheId ,
142
- modified : 0
142
+ modified : 0 ,
143
+ hash : util . hash ( 'b' ) . toString ( 'hex' )
143
144
} )
144
145
] ) . then ( ( ) => box . process ( ) ) . then ( ( ) => {
145
146
const file = processor . args [ 0 ] [ 0 ] ;
@@ -148,7 +149,7 @@ describe('Box', () => {
148
149
} ) . finally ( ( ) => fs . rmdir ( box . base ) ) ;
149
150
} ) ;
150
151
151
- it ( 'process() - hash changed' , ( ) => {
152
+ it ( 'process() - skip (mtime changed but hash matched) ' , ( ) => {
152
153
const box = newBox ( 'test' ) ;
153
154
const name = 'a.txt' ;
154
155
const path = pathFn . join ( box . base , name ) ;
@@ -158,15 +159,38 @@ describe('Box', () => {
158
159
box . addProcessor ( processor ) ;
159
160
160
161
return fs . writeFile ( path , 'a' ) . then ( ( ) => fs . stat ( path ) ) . then ( stats => box . Cache . insert ( {
161
- _id : cacheId
162
+ _id : cacheId ,
163
+ modified : 0 ,
164
+ hash : util . hash ( 'a' ) . toString ( 'hex' )
162
165
} ) ) . then ( ( ) => box . process ( ) ) . then ( ( ) => {
163
166
const file = processor . args [ 0 ] [ 0 ] ;
164
- file . type . should . eql ( 'update' ) ;
167
+ file . type . should . eql ( 'skip' ) ;
168
+ file . path . should . eql ( name ) ;
169
+ } ) . finally ( ( ) => fs . rmdir ( box . base ) ) ;
170
+
171
+ } ) ;
172
+
173
+ it ( 'process() - skip (hash changed but mtime matched)' , ( ) => {
174
+ const box = newBox ( 'test' ) ;
175
+ const name = 'a.txt' ;
176
+ const path = pathFn . join ( box . base , name ) ;
177
+ const cacheId = 'test/' + name ;
178
+
179
+ const processor = sinon . spy ( ) ;
180
+ box . addProcessor ( processor ) ;
181
+
182
+ return fs . writeFile ( path , 'a' ) . then ( ( ) => fs . stat ( path ) ) . then ( stats => box . Cache . insert ( {
183
+ _id : cacheId ,
184
+ modified : stats . mtime ,
185
+ hash : util . hash ( 'b' ) . toString ( 'hex' )
186
+ } ) ) . then ( ( ) => box . process ( ) ) . then ( ( ) => {
187
+ const file = processor . args [ 0 ] [ 0 ] ;
188
+ file . type . should . eql ( 'skip' ) ;
165
189
file . path . should . eql ( name ) ;
166
190
} ) . finally ( ( ) => fs . rmdir ( box . base ) ) ;
167
191
} ) ;
168
192
169
- it ( 'process() - skip' , ( ) => {
193
+ it ( 'process() - skip (mtime matched and hash matched) ' , ( ) => {
170
194
const box = newBox ( 'test' ) ;
171
195
const name = 'a.txt' ;
172
196
const path = pathFn . join ( box . base , name ) ;
0 commit comments