Only write update bolt piece completion if the existing value differs

This commit is contained in:
Matt Joiner 2021-02-22 14:51:34 +11:00
parent 7f7c59d52e
commit ac05b69e11
1 changed files with 3 additions and 0 deletions

View File

@ -67,6 +67,9 @@ func (me boltPieceCompletion) Get(pk metainfo.PieceKey) (cn Completion, err erro
}
func (me boltPieceCompletion) Set(pk metainfo.PieceKey, b bool) error {
if c, err := me.Get(pk); err == nil && c.Ok && c.Complete == b {
return nil
}
return me.db.Update(func(tx *bbolt.Tx) error {
c, err := tx.CreateBucketIfNotExists(completionBucketKey)
if err != nil {