From 75b6558063852aa5906fe06298c43a2b2b6f4c60 Mon Sep 17 00:00:00 2001 From: Lukas Plevac Date: Fri, 29 Dec 2023 08:40:49 +0000 Subject: [PATCH 1/2] Added auto fail observation when timeout --- web/API/crons.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/web/API/crons.php b/web/API/crons.php index a2b1dfa..d66d61e 100644 --- a/web/API/crons.php +++ b/web/API/crons.php @@ -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==? && startstatus->getVal("assigned"), time() - 300]); + + foreach ($fob in $faild->values) { + $fob->status->set("fail"); + $fob->commit(); + } + } \ No newline at end of file From bbb5de3900713e6432921533df4e0c7aa1e98517 Mon Sep 17 00:00:00 2001 From: Lukas Plevac Date: Fri, 29 Dec 2023 08:41:04 +0000 Subject: [PATCH 2/2] Added support for chunk upload --- web/API/observations.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/web/API/observations.php b/web/API/observations.php index cdc959b..08f5e7d 100644 --- a/web/API/observations.php +++ b/web/API/observations.php @@ -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); }