]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Modify .status dir running to return the output as a flow
authorEric Bollengier <eric@baculasystems.com>
Thu, 13 Oct 2022 16:05:05 +0000 (18:05 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:59 +0000 (13:56 +0200)
bacula/src/dird/ua_status.c

index 10763da265419dd2e0fb00ee834144a956430cf3..df13099b30fc624de778383058c6ab6f3fc690da 100644 (file)
@@ -1259,7 +1259,7 @@ static void list_running_jobs(UAContext *ua)
 
    } else if (ua->api > 1) {    // We always return something in APIv2
       ow.start_group("running");
-      ow.get_output(OT_START_ARRAY, OT_END);
+      ua->send_msg("%s", ow.get_output(OT_START_ARRAY, OT_END));
    }
 
    njobs = 0; /* count the number of job really displayed */
@@ -1454,27 +1454,31 @@ static void list_running_jobs(UAContext *ua)
          STORE    *w = wstore;
          STORE    *r = rstore;
          JOB      *j = jcr->job;
-         ow.get_output(OT_START_OBJ,
-                       OT_INT32,   "jobid",     jcr->JobId,
-                       OT_JOBLEVEL,"level",     jcr->getJobLevel(),
-                       OT_JOBTYPE, "type",      jcr->getJobType(),
-                       OT_JOBSTATUS,"status",   status,
-                       OT_STRING,  "status_desc",msg_buf.c_str(),
-                       OT_STRING,  "comment",   jcr->comment,
-                       OT_SIZE,    "jobbytes",  jcr->JobBytes,
-                       OT_INT32,   "jobfiles",  jcr->JobFiles,
-                       OT_STRING,  "job",       jcr->Job,
-                       OT_STRING,  "name",      j?j->name():"",
-                       OT_STRING,  "clientname",c?c->name():"",
-                       OT_STRING,  "fileset",   f?f->name():"",
-                       OT_STRING,  "storage",   w?w->name():"",
-                       OT_STRING,  "rstorage",  r?r->name():"",
-                       OT_UTIME,   "schedtime", jcr->sched_time,
-                       OT_UTIME,   "starttime", jcr->start_time,
-                       OT_INT32,   "priority",  jcr->JobPriority,
-                       OT_INT32,   "errors",    jcr->JobErrors,
-                       OT_END_OBJ,
-                       OT_END);
+         ua->send_msg("%s",
+                      ow.get_output(OT_CLEAR,
+                                    (njobs > 1) ? OT_SEP : OT_NOP,
+                                    OT_START_OBJ,
+                                    OT_INT32,   "jobid",     jcr->JobId,
+                                    OT_JOBLEVEL,"level",     jcr->getJobLevel(),
+                                    OT_JOBTYPE, "type",      jcr->getJobType(),
+                                    OT_JOBSTATUS,"status",   status,
+                                    OT_STRING,  "status_desc",msg_buf.c_str(),
+                                    OT_STRING,  "comment",   jcr->comment,
+                                    OT_SIZE,    "jobbytes",  jcr->JobBytes,
+                                    OT_INT32,   "jobfiles",  jcr->JobFiles,
+                                    OT_STRING,  "job",       jcr->Job,
+                                    OT_STRING,  "name",      j?j->name():"",
+                                    OT_STRING,  "clientname",c?c->name():"",
+                                    OT_STRING,  "fileset",   f?f->name():"",
+                                    OT_STRING,  "storage",   w?w->name():"",
+                                    OT_STRING,  "rstorage",  r?r->name():"",
+                                    OT_UTIME,   "schedtime", jcr->sched_time,
+                                    OT_UTIME,   "starttime", jcr->start_time,
+                                    OT_INT32,   "priority",  jcr->JobPriority,
+                                    OT_INT32,   "errors",    jcr->JobErrors,
+                                    OT_END_OBJ,
+                                    OT_END)
+            );
 
       } else {
          char b1[50], b2[50], b3[50];
@@ -1491,9 +1495,9 @@ static void list_running_jobs(UAContext *ua)
    endeach_jcr(jcr);
 
    if (ua->api > 1) {
+      ow.get_output(OT_CLEAR, OT_END);
       ow.end_list();
-      char *p = ow.end_group();
-      ua->send_msg("%s", p);
+      ua->send_msg("%s", ow.end_group());
    }
 
    if (njobs == 0) {