This commit is contained in:
Lukáš Plevač 2023-12-29 09:48:11 +01:00
commit 4cfce6e23a
2 changed files with 34 additions and 8 deletions

View File

@ -2,7 +2,8 @@
namespace API\cron;
function all($params) {
tle($params);
autoFail($params);
}
function tle($params) {
@ -36,4 +37,17 @@
}
return $updated;
}
function autoFail($params) {
$observations = new \wsos\database\core\table(\DAL\observation::class);
$ob = new \DAL\observation();
$faild = $observations->query("status==? && start<?", [$ob->status->getVal("assigned"), time() - 300]);
foreach ($fob in $faild->values) {
$fob->status->set("fail");
$fob->commit();
}
}

View File

@ -132,14 +132,26 @@
$adir = __DIR__ . "/../ARTEFACTS/" . $params["id"];
$fname = basename($params["fname"]);
mkdir($adir, 0777, true);
$artefacts = $obs->artefacts->get();
foreach ($_FILES as $file) {
move_uploaded_file($file["tmp_name"], $adir . "/" . $file["name"]);
$artefacts[] = "/ARTEFACTS/{$params['id']}/{$file['name']}";
// chunk upload file
if ($params["offset"] == 0) {
// get current artifasts
$artefacts = $obs->artefacts->get();
$artefacts[] = "/ARTEFACTS/{$params['id']}/{$fname}";
$obs->artefacts->set($artefacts);
$obs->commit();
}
$obs->artefacts->set($artefacts);
$obs->commit();
// file pointer
$ifp = fopen($adir . "/" . $fname, 'ab');
fwrite($ifp, $params["data"]);
// clean up the file resource
fclose($ifp);
}