@@ -201,20 +201,6 @@ func (db *DB) setSync(batch *leveldb.Batch, addr chunk.Address, mode chunk.ModeS
201
201
item .StoreTimestamp = i .StoreTimestamp
202
202
item .BinID = i .BinID
203
203
204
- i , err = db .retrievalAccessIndex .Get (item )
205
- switch err {
206
- case nil :
207
- item .AccessTimestamp = i .AccessTimestamp
208
- db .gcIndex .DeleteInBatch (batch , item )
209
- gcSizeChange --
210
- case leveldb .ErrNotFound :
211
- // the chunk is not accessed before
212
- default :
213
- return 0 , err
214
- }
215
- item .AccessTimestamp = now ()
216
- db .retrievalAccessIndex .PutInBatch (batch , item )
217
-
218
204
// moveToGc toggles the deletion of the item from pushsync index
219
205
// it will be false in the case pull sync was called but push sync was meant on that chunk (!tag.Anonymous)
220
206
moveToGc := true
@@ -258,6 +244,20 @@ func (db *DB) setSync(batch *leveldb.Batch, addr chunk.Address, mode chunk.ModeS
258
244
if ! moveToGc {
259
245
return 0 , nil
260
246
}
247
+
248
+ i , err = db .retrievalAccessIndex .Get (item )
249
+ switch err {
250
+ case nil :
251
+ item .AccessTimestamp = i .AccessTimestamp
252
+ db .gcIndex .DeleteInBatch (batch , item )
253
+ gcSizeChange --
254
+ case leveldb .ErrNotFound :
255
+ // the chunk is not accessed before
256
+ default :
257
+ return 0 , err
258
+ }
259
+ item .AccessTimestamp = now ()
260
+ db .retrievalAccessIndex .PutInBatch (batch , item )
261
261
db .pushIndex .DeleteInBatch (batch , item )
262
262
263
263
// Add in gcIndex only if this chunk is not pinned
0 commit comments