"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
rc: add jobs stats
n4n5833559620759
diff --git a/fs/rc/jobs/job.go b/fs/rc/jobs/job.goindex e8b141ead..1a7976c27 100644--- a/fs/rc/jobs/job.go+++ b/fs/rc/jobs/job.go@@ -189,6 +189,22 @@ func (jobs *Jobs) IDs() (IDs []int64) {return IDs}+// Stats returns the IDs of the running and finished jobs+func (jobs *Jobs) Stats() (running []int64, finished []int64) {+ jobs.mu.RLock()+ defer jobs.mu.RUnlock()+ running = []int64{}+ finished = []int64{}+ for jobID := range jobs.jobs {+ if jobs.jobs[jobID].Finished {+ finished = append(finished, jobID)+ } else {+ running = append(running, jobID)+ }+ }+ return running, finished+}+// Get a job with a given ID or nil if it doesn't existfunc (jobs *Jobs) Get(ID int64) *Job {jobs.mu.RLock()@@ -409,6 +425,8 @@ Results:- executeId - string id of rclone executing (change after restart)- jobids - array of integer job ids (starting at 1 on each restart)+- running_ids - array of integer job ids that are running+- finished_ids - array of integer job ids that are finished`,})}@@ -417,6 +435,9 @@ Results:func rcJobList(ctx context.Context, in rc.Params) (out rc.Params, err error) {out = make(rc.Params)out["jobids"] = running.IDs()+ runningIDs, finishedIDs := running.Stats()+ out["running_ids"] = runningIDs+ out["finished_ids"] = finishedIDsout["executeId"] = executeIDreturn out, nil}diff --git a/fs/rc/jobs/job_test.go b/fs/rc/jobs/job_test.goindex e06ba467f..616ad0ef2 100644--- a/fs/rc/jobs/job_test.go+++ b/fs/rc/jobs/job_test.go@@ -378,6 +378,8 @@ func TestRcJobList(t *testing.T) {require.NoError(t, err)require.NotNil(t, out1)assert.Equal(t, []int64{1}, out1["jobids"], "should have job listed")+ assert.Equal(t, []int64{1}, out1["running_ids"], "should have running job")+ assert.Equal(t, []int64{}, out1["finished_ids"], "should not have finished job")_, _, err = NewJob(ctx, longFn, rc.Params{"_async": true})assert.NoError(t, err)