* Finish task #83362.

This commit is contained in:
zhaoke
2023-02-02 09:16:09 +00:00
parent 597b77af82
commit ffcc487808
10 changed files with 130 additions and 20 deletions
+11 -2
View File
@@ -23,7 +23,7 @@ class hostSubmitEntry extends baseEntry
/* Check authorize. */
$header = getallheaders();
$token = isset($header['Authorization']) ? substr($header['Authorization'], 7) : '';
// if(!$token) return $this->sendError(401, 'Unauthorized');
if(!$token) return $this->sendError(401, 'Unauthorized');
$now = helper::now();
@@ -38,7 +38,16 @@ class hostSubmitEntry extends baseEntry
->andWhere('tokenTime')->gt($now)->fi()
->fetch('id');
// if(!$id) return $this->sendError(400, 'Secret error.');
if(!$id) return $this->sendError(400, 'Secret error.');
$imageInfo = $this->dao->select('`status`,`from`')->from(TABLE_IMAGE)
->where('id')->eq($task)
->fetch();
if(empty($imageInfo)) return $this->sendSuccess(200, 'success');
if($imageInfo->from == 'snapshot' && $imageInfo->status == 'restoring')
{
$image->status = $image->status == 'completed' ? 'restore_completed' : 'restore_failed';
}
$this->dao->update(TABLE_IMAGE)->data($image)->where("id")->eq($task)->exec();