mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
rc: add execute-id for job-id
This commit is contained in:
parent
10449c86a4
commit
5b63b9534f
@ -10,6 +10,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/accounting"
|
||||
"github.com/rclone/rclone/fs/cache"
|
||||
@ -120,8 +121,9 @@ type Jobs struct {
|
||||
}
|
||||
|
||||
var (
|
||||
running = newJobs()
|
||||
jobID = int64(0)
|
||||
running = newJobs()
|
||||
jobID = int64(0)
|
||||
executeID = uuid.New().String()
|
||||
)
|
||||
|
||||
// newJobs makes a new Jobs structure
|
||||
@ -403,7 +405,8 @@ func init() {
|
||||
|
||||
Results:
|
||||
|
||||
- jobids - array of integer job ids.
|
||||
- executeId - string id of rclone executing (change after restart)
|
||||
- jobids - array of integer job ids (starting at 1 on each restart)
|
||||
`,
|
||||
})
|
||||
}
|
||||
@ -412,6 +415,7 @@ Results:
|
||||
func rcJobList(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
||||
out = make(rc.Params)
|
||||
out["jobids"] = running.IDs()
|
||||
out["executeId"] = executeID
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
@ -374,10 +374,24 @@ func TestRcJobList(t *testing.T) {
|
||||
call := rc.Calls.Get("job/list")
|
||||
assert.NotNil(t, call)
|
||||
in := rc.Params{}
|
||||
out, err := call.Fn(context.Background(), in)
|
||||
out1, err := call.Fn(context.Background(), in)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, out)
|
||||
assert.Equal(t, rc.Params{"jobids": []int64{1}}, out)
|
||||
require.NotNil(t, out1)
|
||||
assert.Equal(t, []int64{1}, out1["jobids"], "should have job listed")
|
||||
|
||||
_, _, err = NewJob(ctx, longFn, rc.Params{"_async": true})
|
||||
assert.NoError(t, err)
|
||||
|
||||
call = rc.Calls.Get("job/list")
|
||||
assert.NotNil(t, call)
|
||||
in = rc.Params{}
|
||||
out2, err := call.Fn(context.Background(), in)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, out2)
|
||||
assert.Equal(t, 2, len(out2["jobids"].([]int64)), "should have all jobs listed")
|
||||
|
||||
require.NotNil(t, out1["executeId"], "should have executeId")
|
||||
assert.Equal(t, out1["executeId"], out2["executeId"], "executeId should be the same")
|
||||
}
|
||||
|
||||
func TestRcAsyncJobStop(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user