fix: installation error in command line

pull/104/head
HFO4 7 years ago
parent 9ee144d870
commit 96b7f4c97d

@ -5,6 +5,7 @@ use think\Controller;
use think\Db; use think\Db;
use think\Request; use think\Request;
use \app\index\model\Task;
use \app\index\model\Option; use \app\index\model\Option;
class Queue extends Controller{ class Queue extends Controller{
@ -29,6 +30,8 @@ class Queue extends Controller{
public function getList(){ public function getList(){
$size = input("get.num"); $size = input("get.num");
$tasks = Db::name("task")->where("status","todo")->limit($size)->select(); $tasks = Db::name("task")->where("status","todo")->limit($size)->select();
$taskID = array_column($tasks,"id");
Db::name("task")->where("id","in",$taskID)->update(["status"=>"processing"]);
if(empty($tasks)){ if(empty($tasks)){
return "none"; return "none";
}else{ }else{
@ -36,4 +39,40 @@ class Queue extends Controller{
} }
} }
public function getPolicy(){
$id = input("get.id");
$policy = Db::name("policy")->where("id",$id)->find();
if(empty(($policy))){
abort(404);
}else{
return json($policy);
}
}
public function setSuccess(){
$id = input("get.id");
$task = new Task($id);
$task->taskModel = Db::name("task")
->where("id",$id)
//->where("status","processing")
->find();
if(empty($task->taskModel)){
return json(["error"=>true,"msg"=>"未找到任务"]);
}
return json($task->setSuccess());
}
public function setError(){
$id = input("get.id");
$task = new Task($id);
$task->taskModel = Db::name("task")
->where("id",$id)
//->where("status","processing")
->find();
if(empty($task->taskModel)){
return json(["error"=>true,"msg"=>"未找到任务"]);
}
return json($task->Error());
}
} }

@ -293,7 +293,7 @@ class Aria2 extends Model{
"originPath" => $quenInfo["files"][$sqlData["file_index"]]["path"], "originPath" => $quenInfo["files"][$sqlData["file_index"]]["path"],
"objname" => $fileName, "objname" => $fileName,
"savePath" => $generatePath, "savePath" => $generatePath,
"fsize" => $quenInfo["files"][$sqlData["file_index"]]["length"], "fsize" => (int)$quenInfo["files"][$sqlData["file_index"]]["length"],
"picInfo" => $picInfo, "picInfo" => $picInfo,
"policyId" => $this->policy["id"], "policyId" => $this->policy["id"],
]); ]);

@ -350,6 +350,63 @@ class Task extends Model{
FileManage::storageGiveBack($this->taskModel["uid"],$this->taskContent["fsize"]); FileManage::storageGiveBack($this->taskModel["uid"],$this->taskContent["fsize"]);
} }
public function setSuccess(){
$this->taskContent = json_decode($this->taskModel["attr"],true);
$policyData = Db::name("policy")->where("id",$this->taskContent["policyId"])->find();
$this->policyModel = $policyData;
$onedrive = new Client([
'stream_back_end' => \Krizalys\Onedrive\StreamBackEnd::TEMP,
'client_id' => $policyData["bucketname"],
// Restore the previous state while instantiating this client to proceed in
// obtaining an access token.
'state' => json_decode($policyData["sk"]),
]);
$jsonData = array(
"path" => $this->taskContent["path"],
"fname" => $this->taskContent["fname"],
"objname" => $this->taskContent["savePath"]."/".$this->taskContent["objname"],
"fsize" => $this->taskContent["fsize"],
);
$addAction = FileManage::addFile($jsonData,$policyData,$this->taskModel["uid"],$this->taskContent["picInfo"]);
if(!$addAction[0]){
$this->setError($addAction[1],true,"/me/drive/root:/".$this->taskContent["savePath"]."/".rawurlencode($this->taskContent["objname"]),$onedrive);
$this->cleanTmpFile();
Db::name("task")->where("id",$this->taskModel["id"])->update(["status"=>"error|".$this->errorMsg]);
return ["error"=>true,"msg"=>$this->errorMsg];
}
$this->cleanTmpFile();
if($this->taskModel["type"] == "UploadLargeRemoteDownloadFileToOnedrive" || $this->taskModel["type"] == "uploadChunksToOnedrive"){
$this->cleanTmpChunk();
}
Db::name("task")->where("id",$this->taskModel["id"])->update(["status"=>"complete"]);
return ["error"=>false,"msg"=>null];
}
public function Error(){
$this->taskContent = json_decode($this->taskModel["attr"],true);
$policyData = Db::name("policy")->where("id",$this->taskContent["policyId"])->find();
$this->policyModel = $policyData;
$onedrive = new Client([
'stream_back_end' => \Krizalys\Onedrive\StreamBackEnd::TEMP,
'client_id' => $policyData["bucketname"],
// Restore the previous state while instantiating this client to proceed in
// obtaining an access token.
'state' => json_decode($policyData["sk"]),
]);
$this->setError("",false,"/me/drive/root:/".$this->taskContent["savePath"]."/".rawurlencode($this->taskContent["objname"]),$onedrive);
$this->cleanTmpFile();
if($this->taskModel["type"] == "UploadLargeRemoteDownloadFileToOnedrive" || $this->taskModel["type"] == "uploadChunksToOnedrive"){
$this->cleanTmpChunk();
}
Db::name("task")->where("id",$this->taskModel["id"])->update(["status"=>"error"]);
}
} }
?> ?>

@ -201,7 +201,7 @@ INSERT INTO `sd_options` (`id`, `option_name`, `option_value`, `option_type`) VA
(53, 'aria2_token', 'your token', 'aria2'), (53, 'aria2_token', 'your token', 'aria2'),
(54, 'aria2_rpcurl', 'http://127.0.0.1:6800/', 'aria2'), (54, 'aria2_rpcurl', 'http://127.0.0.1:6800/', 'aria2'),
(55, 'aria2_options', '{\"max-tries\":5}', 'aria2'), (55, 'aria2_options', '{\"max-tries\":5}', 'aria2'),
(NULL, 'task_queue_token', '', 'task'); (56, 'task_queue_token', '', 'task');
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Loading…
Cancel
Save