* rc/jobs: Add SetInitialJobID function that allows for setting the jobID

This commit is contained in:
Michal Matczuk 2019-08-21 12:01:39 +02:00 committed by Nick Craig-Wood
parent 82c6c77e07
commit 5d6593de4f
1 changed files with 9 additions and 4 deletions

View File

@ -10,12 +10,10 @@ import (
"sync/atomic"
"time"
"github.com/rclone/rclone/fs/rc"
"github.com/rclone/rclone/fs/accounting"
"github.com/pkg/errors"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/accounting"
"github.com/rclone/rclone/fs/rc"
)
// Job describes a asynchronous task started via the rc package
@ -59,6 +57,13 @@ func SetOpt(opt *rc.Options) {
running.opt = opt
}
// SetInitialJobID allows for setting jobID before starting any jobs.
func SetInitialJobID(id int64) {
if !atomic.CompareAndSwapInt64(&jobID, 0, id) {
panic("Setting jobID is only possible before starting any jobs")
}
}
// kickExpire makes sure Expire is running
func (jobs *Jobs) kickExpire() {
jobs.mu.Lock()