29 require_once (dirname(__FILE__) .
'/../php/pathinclude.php');
32 require_once (
"$WEBDIR/common/common.php");
34 error_reporting(E_NOTICE & E_STRICT);
42 function AddReunpackjob ($uploadpk,$Depends=NULL,$priority=0)
48 $Job_name = str_replace(
"'",
"''",
"unpack");
50 $SQLInsert =
"INSERT INTO job 51 (job_queued,job_priority,job_name,job_upload_fk) VALUES 52 (now(),'$priority','$Job_name','$uploadpk');";
54 $SQLcheck =
"SELECT job_pk FROM job WHERE job_upload_fk = '$uploadpk' AND job_name = '$Job_name' AND job_user_fk is NULL;";
55 $Results = $DB->Action($SQLcheck);
56 if (!empty($Results)){
57 $jobpk = $Results[0][
'job_pk'];
59 $DB->Action($SQLInsert);
60 $SQLcheck =
"SELECT job_pk FROM job WHERE job_upload_fk = '$uploadpk' AND job_name = '$Job_name' AND job_user_fk is NULL;";
61 $Results = $DB->Action($SQLcheck);
62 $jobpk = $Results[0][
'job_pk'];
65 if (empty($jobpk) || ($jobpk < 0)) {
return(
"Failed to insert job record! $SQLInsert"); }
66 if (!empty($Depends) && !is_array($Depends)) { $Depends = array($Depends); }
69 $jqargs =
"SELECT pfile.pfile_sha1 || '.' || pfile.pfile_md5 || '.' || pfile.pfile_size AS pfile, 72 INNER JOIN pfile ON upload.pfile_fk = pfile.pfile_pk 73 WHERE upload.upload_pk = '$uploadpk';";
74 $jobqueuepk =
JobQueueAdd($jobpk,
"unpack",$jqargs,
"no",
"pfile",$Depends,1);
75 if (empty($jobqueuepk)) {
return(
"Failed to insert item into job queue"); }
85 $SQL =
"SELECT job_pk,jq_pk,job_upload_fk FROM jobqueue 86 INNER JOIN job ON jq_job_fk = job_pk 87 WHERE jq_end_bits = 0 AND jq_starttime IS NOT NULL AND jq_endtime IS NULL AND job_name NOT IN('unpack','wget','fo_notify') 89 $Results = $DB->Action($SQL);
91 while(!empty($Results[$i][
'job_pk'])) {
92 $jq_parent = AddReunpackjob($Results[$i][
'job_upload_fk']);
94 $jq_child = $Results[$i][
'jq_pk'];
95 JobQueueAddDependency($jq_child,$jq_parent);
JobQueueAdd($job_pk, $jq_type, $jq_args, $jq_runonpfile, $Depends, $host=NULL, $jq_cmd_args=NULL)
Insert a jobqueue + jobdepends records.
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...