Skip to content

Commit

Permalink
change user size calculation to addObjectsToDatabase() once pinned
Browse files Browse the repository at this point in the history
  • Loading branch information
LucRoy committed May 17, 2023
1 parent aefa166 commit 21180d2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pinner/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ func (m *manager) addObjectsToDatabase(ctx context.Context, cont *util.Content,
return xerrors.Errorf("failed to update content in database: %w", err)
}

var usc *util.UsersStorageCapacity
err := tx.First(&usc, "user_id = ?", cont.UserID).Error
if err != nil {
usc.UserId = cont.UserID
usc.Size = 0
}

usc.Size += contSize
tx.Save(&usc)

// if content can be staged, stage it
if contSize < m.cfg.Content.MinSize {
return m.stgZoneQueueMgr.QueueContent(cont, tx, false)
Expand Down

0 comments on commit 21180d2

Please sign in to comment.