Submit derive task after all uploads completed

This commit is contained in:
2026-06-05 12:56:11 +01:00
parent 34d8014bac
commit 44995c4e6a
5 changed files with 78 additions and 3 deletions
+28 -3
View File
@@ -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);
}
}
+4
View File
@@ -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, [