Commit 828d95cd authored by Janoš Guljaš's avatar Janoš Guljaš Committed by GitHub

add to localstore gc index on ModePutSync (#973)

parent 7191e6a6
...@@ -235,7 +235,7 @@ func (db *DB) putUpload(batch *leveldb.Batch, binIDs map[uint8]uint64, item shed ...@@ -235,7 +235,7 @@ func (db *DB) putUpload(batch *leveldb.Batch, binIDs map[uint8]uint64, item shed
} }
// putSync adds an Item to the batch by updating required indexes: // putSync adds an Item to the batch by updating required indexes:
// - put to indexes: retrieve, pull // - put to indexes: retrieve, pull, gc
// The batch can be written to the database. // The batch can be written to the database.
// Provided batch and binID map are updated. // Provided batch and binID map are updated.
func (db *DB) putSync(batch *leveldb.Batch, binIDs map[uint8]uint64, item shed.Item) (exists bool, gcSizeChange int64, err error) { func (db *DB) putSync(batch *leveldb.Batch, binIDs map[uint8]uint64, item shed.Item) (exists bool, gcSizeChange int64, err error) {
...@@ -260,6 +260,10 @@ func (db *DB) putSync(batch *leveldb.Batch, binIDs map[uint8]uint64, item shed.I ...@@ -260,6 +260,10 @@ func (db *DB) putSync(batch *leveldb.Batch, binIDs map[uint8]uint64, item shed.I
if err != nil { if err != nil {
return false, 0, err return false, 0, err
} }
gcSizeChange, err = db.setGC(batch, item)
if err != nil {
return false, 0, err
}
return false, gcSizeChange, nil return false, gcSizeChange, nil
} }
......
...@@ -107,9 +107,11 @@ func TestModePutSync(t *testing.T) { ...@@ -107,9 +107,11 @@ func TestModePutSync(t *testing.T) {
po := db.po(ch.Address()) po := db.po(ch.Address())
binIDs[po]++ binIDs[po]++
newRetrieveIndexesTest(db, ch, wantTimestamp, 0)(t) newRetrieveIndexesTestWithAccess(db, ch, wantTimestamp, wantTimestamp)(t)
newPullIndexTest(db, ch, binIDs[po], nil)(t) newPullIndexTest(db, ch, binIDs[po], nil)(t)
newPinIndexTest(db, ch, leveldb.ErrNotFound)(t) newPinIndexTest(db, ch, leveldb.ErrNotFound)(t)
newItemsCountTest(db.gcIndex, tc.count)(t)
newIndexGCSizeTest(db)(t)
} }
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment