mirror of
https://github.com/tuna/tunasync.git
synced 2025-06-14 13:32:43 +00:00
bug fix: tunasynctl failed to parse datetime when you list jobs of specific worker
This commit is contained in:
parent
ef78563b8c
commit
6241576b12
@ -140,8 +140,9 @@ func listWorkers(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func listJobs(c *cli.Context) error {
|
func listJobs(c *cli.Context) error {
|
||||||
var jobs []tunasync.WebMirrorStatus
|
var genericJobs interface{}
|
||||||
if c.Bool("all") {
|
if c.Bool("all") {
|
||||||
|
var jobs []tunasync.WebMirrorStatus
|
||||||
_, err := tunasync.GetJSON(baseURL+listJobsPath, &jobs, client)
|
_, err := tunasync.GetJSON(baseURL+listJobsPath, &jobs, client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(
|
return cli.NewExitError(
|
||||||
@ -149,18 +150,20 @@ func listJobs(c *cli.Context) error {
|
|||||||
"of all jobs from manager server: %s", err.Error()),
|
"of all jobs from manager server: %s", err.Error()),
|
||||||
1)
|
1)
|
||||||
}
|
}
|
||||||
|
genericJobs = jobs
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
var jobs []tunasync.MirrorStatus
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return cli.NewExitError(
|
return cli.NewExitError(
|
||||||
fmt.Sprintf("Usage Error: jobs command need at"+
|
fmt.Sprintf("Usage Error: jobs command need at"+
|
||||||
" least one arguments or \"--all\" flag."), 1)
|
" least one arguments or \"--all\" flag."), 1)
|
||||||
}
|
}
|
||||||
ans := make(chan []tunasync.WebMirrorStatus, len(args))
|
ans := make(chan []tunasync.MirrorStatus, len(args))
|
||||||
for _, workerID := range args {
|
for _, workerID := range args {
|
||||||
go func(workerID string) {
|
go func(workerID string) {
|
||||||
var workerJobs []tunasync.WebMirrorStatus
|
var workerJobs []tunasync.MirrorStatus
|
||||||
_, err := tunasync.GetJSON(fmt.Sprintf("%s/workers/%s/jobs",
|
_, err := tunasync.GetJSON(fmt.Sprintf("%s/workers/%s/jobs",
|
||||||
baseURL, workerID), &workerJobs, client)
|
baseURL, workerID), &workerJobs, client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -173,9 +176,10 @@ func listJobs(c *cli.Context) error {
|
|||||||
for range args {
|
for range args {
|
||||||
jobs = append(jobs, <-ans...)
|
jobs = append(jobs, <-ans...)
|
||||||
}
|
}
|
||||||
|
genericJobs = jobs
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := json.MarshalIndent(jobs, "", " ")
|
b, err := json.MarshalIndent(genericJobs, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(
|
return cli.NewExitError(
|
||||||
fmt.Sprintf("Error printing out informations: %s", err.Error()),
|
fmt.Sprintf("Error printing out informations: %s", err.Error()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user