From 4e877b0d4c948a8c0fda7848216c9bc00f55f722 Mon Sep 17 00:00:00 2001 From: mike76-dev Date: Mon, 18 Dec 2023 14:16:36 +0100 Subject: [PATCH] Upload as long as there are files pending --- modules/manager/contractor/database.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/manager/contractor/database.go b/modules/manager/contractor/database.go index 86c4b5b..cd059c4 100644 --- a/modules/manager/contractor/database.go +++ b/modules/manager/contractor/database.go @@ -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") @@ -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 +}