Submit derive task after all uploads completed
This commit is contained in:
+28
-3
@@ -26,7 +26,7 @@ class Archive {
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Error $resp processing tasks");
|
||||
throw new Exception($req->body);
|
||||
}
|
||||
|
||||
static function upload(File $file, $identifier, $filename, $metadata = [], ?Callable $callback = null) {
|
||||
@@ -56,6 +56,8 @@ class Archive {
|
||||
}
|
||||
}
|
||||
|
||||
$headers[] = "content-type:application/pdf";
|
||||
|
||||
|
||||
$req = new HTTPRequest();
|
||||
if ($callback) {
|
||||
@@ -66,7 +68,7 @@ class Archive {
|
||||
if ($resp == 200) {
|
||||
return true;
|
||||
}
|
||||
throw new Exception($req->body);
|
||||
throw new Exception($resp . ": " . $req->body);
|
||||
}
|
||||
|
||||
static function metadata($identifier) {
|
||||
@@ -84,7 +86,30 @@ class Archive {
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Error " . $resp . " during metadata get");
|
||||
throw new Exception($resp . ": " . $req->body);
|
||||
}
|
||||
|
||||
static function derive($identifier) {
|
||||
$req = new HTTPRequest();
|
||||
|
||||
$data = [
|
||||
"identifier" => $identifier,
|
||||
"cmd" => "derive.php",
|
||||
"args" => [],
|
||||
"priority" => 0
|
||||
];
|
||||
|
||||
$resp = $req->post("https://archive.org/services/tasks.php", json_encode($data), [
|
||||
"Authorization: LOW " . Config::get("ARCHIVE_KEY") . ":" . Config::get("ARCHIVE_SECRET"),
|
||||
"content-type:application/json",
|
||||
]);
|
||||
|
||||
if ($resp == 200) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new Exception($resp . ": " . $req->body);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ abstract class Job {
|
||||
|
||||
// Mark the job as failed miserably
|
||||
public function fail($message = "") {
|
||||
if (is_terminal()) {
|
||||
print(" !! " . $message . "\n");
|
||||
}
|
||||
|
||||
$db = DB::getInstance();
|
||||
if ($message != "") {
|
||||
$db->update("job", $this->_jobid, [
|
||||
|
||||
Reference in New Issue
Block a user