Skip to content

Commit

Permalink
Upload as long as there are files pending
Browse files Browse the repository at this point in the history
  • Loading branch information
mike76-dev committed Dec 18, 2023
1 parent 1cba1be commit 4e877b0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modules/manager/contractor/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,14 @@ func (c *Contractor) managedUploadBufferedFiles() {
c.mu.Lock()
c.uploadingBufferedFiles = false
c.mu.Unlock()
pending, err := c.uploadPending()
if err != nil {
c.log.Println("ERROR: couldn't check files pending upload")
return
}
if pending {
go c.managedUploadBufferedFiles()
}
}()

c.log.Println("INFO: uploading buffered files")
Expand Down Expand Up @@ -1746,3 +1754,11 @@ func (c *Contractor) threadedPruneOrphanedSlabs() {
c.managedPruneOrphanedSlabs()
}
}

// uploadPending returns true if there is any file pending upload.
func (c *Contractor) uploadPending() (pending bool, err error) {
var count int
err = c.db.QueryRow("SELECT COUNT(*) FROM ctr_uploads").Scan(&count)
pending = count > 0
return
}

0 comments on commit 4e877b0

Please sign in to comment.