src/dird/job.c
int cancel_inactive_job(UAContext *ua)
{
   CLIENT_DBR cr;
   JOB_DBR    jr;
   int        i;
   USTORE     store;
   CLIENT    *client;
   JCR       *jcr = new_jcr(sizeof(JCR), dird_free_jcr);

   memset(&jr, 0, sizeof(jr));
   memset(&cr, 0, sizeof(cr));

   if ((i = find_arg_with_value(ua, "jobid")) > 0) {
      jr.JobId = str_to_int64(ua->argv[i]);

   } else if ((i = find_arg_with_value(ua, "ujobid")) > 0) {
      bstrncpy(jr.Job, ua->argv[i], sizeof(jr.Job));

   } else {
      ua->error_msg(_("jobid/ujobid argument not found.\n"));
      goto bail_out;
   }

   if (!open_client_db(ua)) {
      goto bail_out;
   }

   if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
      ua->error_msg(_("Job %ld/%s not found in database.\n"), jr.JobId, jr.Job);
      goto bail_out;
   }

   if (!acl_access_ok(ua, Job_ACL, jr.Name)) {
      ua->error_msg(_("Job %s is not accessible from this console\n"), jr.Name);
      goto bail_out;
   }

   cr.ClientId = jr.ClientId;
   if (!cr.ClientId || !db_get_client_record(ua->jcr, ua->db, &cr)) {
      ua->error_msg(_("Client %ld not found in database.\n"), jr.ClientId);
      goto bail_out;
   }

   if (acl_access_client_ok(ua, cr.Name, jr.JobType)) {
      client = (CLIENT *)GetResWithName(R_CLIENT, cr.Name);
      if (client) {
         jcr->client = client;
      } else {
         Jmsg1(jcr, M_FATAL, 0, _("Client resource \"%s\" does not exist.\n"), cr.Name);
         goto bail_out;
      }
   } else {
      goto bail_out;
   }

   jcr->JobId = jr.JobId;
   bstrncpy(jcr->Job, jr.Job, sizeof(jcr->Job));

   cancel_file_daemon_job(ua, "cancel", jcr);

   /* At this time, we can't really guess the storage name from
    * the job record
    */
   store.store = get_storage_resource(ua, false/*no default*/, true/*unique*/);
   if (!store.store) {
      goto bail_out;
   }

   set_wstorage(jcr, &store);
   cancel_sd_job(ua, "cancel", jcr);

bail_out:
   jcr->JobId = 0;
   free_jcr(jcr);
   return 1;
}
/* The FD is not connected, so we try to complete JCR fields and send
 * the cancel command.
 */
The FD is not connected, so we try to complete JCR fields and send
the cancel command.
The FD is not connected so we try to complete JCR fields and send the cancel command .
int cancel_inactive_job(UAContext *ua)
{
   CLIENT_DBR cr;
   JOB_DBR    jr;
   int        i;
   USTORE     store;
   CLIENT    *client;
   JCR       *jcr = new_jcr(sizeof(JCR), dird_free_jcr);
   memset(&jr, 0, sizeof(jr));
   memset(&cr, 0, sizeof(cr));
   if ((i = find_arg_with_value(ua, "jobid")) > 0) {
      jr.JobId = str_to_int64(ua->argv[i]);
   } else if ((i = find_arg_with_value(ua, "ujobid")) > 0) {
      bstrncpy(jr.Job, ua->argv[i], sizeof(jr.Job));
   } else {
      ua->error_msg(_("jobid/ujobid argument not found.\n"));
      goto bail_out;
   }
   if (!open_client_db(ua)) {
      goto bail_out;
   }
   if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
      ua->error_msg(_("Job %ld/%s not found in database.\n"), jr.JobId, jr.Job);
      goto bail_out;
   }
   if (!acl_access_ok(ua, Job_ACL, jr.Name)) {
      ua->error_msg(_("Job %s is not accessible from this console\n"), jr.Name);
      goto bail_out;
   }
   cr.ClientId = jr.ClientId;
   if (!cr.ClientId || !db_get_client_record(ua->jcr, ua->db, &cr)) {
      ua->error_msg(_("Client %ld not found in database.\n"), jr.ClientId);
      goto bail_out;
   }
   if (acl_access_client_ok(ua, cr.Name, jr.JobType)) {
      client = (CLIENT *)GetResWithName(R_CLIENT, cr.Name);
      if (client) {
         jcr->client = client;
      } else {
         Jmsg1(jcr, M_FATAL, 0, _("Client resource \"%s\" does not exist.\n"), cr.Name);
         goto bail_out;
      }
   } else {
      goto bail_out;
   }
   jcr->JobId = jr.JobId;
   bstrncpy(jcr->Job, jr.Job, sizeof(jcr->Job));
   cancel_file_daemon_job(ua, "cancel", jcr);
   store.store = get_storage_resource(ua, false, true);
   if (!store.store) {
      goto bail_out;
   }
   set_wstorage(jcr, &store);
   cancel_sd_job(ua, "cancel", jcr);
bail_out:
   jcr->JobId = 0;
   free_jcr(jcr);
   return 1;
}
int cancel_inactive_job ( UAContext * ua ) { CLIENT_DBR cr ; JOB_DBR jr ; int i ; USTORE store ; CLIENT * client ; JCR * jcr = new_jcr ( sizeof ( JCR ) , dird_free_jcr ) ; memset ( & jr , 0 , sizeof ( jr ) ) ; memset ( & cr , 0 , sizeof ( cr ) ) ; if ( ( i = find_arg_with_value ( ua , " " ) ) > 0 ) { jr . JobId = str_to_int64 ( ua -> argv [ i ] ) ; } else if ( ( i = find_arg_with_value ( ua , " " ) ) > 0 ) { bstrncpy ( jr . Job , ua -> argv [ i ] , sizeof ( jr . Job ) ) ; } else { ua -> error_msg ( _ ( " \n " ) ) ; goto bail_out ; } if ( ! open_client_db ( ua ) ) { goto bail_out ; } if ( ! db_get_job_record ( ua -> jcr , ua -> db , & jr ) ) { ua -> error_msg ( _ ( " \n " ) , jr . JobId , jr . Job ) ; goto bail_out ; } if ( ! acl_access_ok ( ua , Job_ACL , jr . Name ) ) { ua -> error_msg ( _ ( " \n " ) , jr . Name ) ; goto bail_out ; } cr . ClientId = jr . ClientId ; if ( ! cr . ClientId || ! db_get_client_record ( ua -> jcr , ua -> db , & cr ) ) { ua -> error_msg ( _ ( " \n " ) , jr . ClientId ) ; goto bail_out ; } if ( acl_access_client_ok ( ua , cr . Name , jr . JobType ) ) { client = ( CLIENT * ) GetResWithName ( R_CLIENT , cr . Name ) ; if ( client ) { jcr -> client = client ; } else { Jmsg1 ( jcr , M_FATAL , 0 , _ ( " \" \" \n " ) , cr . Name ) ; goto bail_out ; } } else { goto bail_out ; } jcr -> JobId = jr . JobId ; bstrncpy ( jcr -> Job , jr . Job , sizeof ( jcr -> Job ) ) ; cancel_file_daemon_job ( ua , " " , jcr ) ; store . store = get_storage_resource ( ua , false , true ) ; if ( ! store . store ) { goto bail_out ; } set_wstorage ( jcr , & store ) ; cancel_sd_job ( ua , " " , jcr ) ; bail_out : jcr -> JobId = 0 ; free_jcr ( jcr ) ; return 1 ; }
The FD is not connected, so we try to complete JCR fields and send
 the cancel command.
The FD is not connected so we try to complete JCR fields and send the cancel command .
/* At this time, we can't really guess the storage name from
    * the job record
    */ /*no default*/ /*unique*/