Commit 52a37824ef73409951f27f3910e12b189fc29c28
1 parent
f656f33b
Exists in
master
1.版本信息添加ECS文件路径,保留原来ECS上传的文件,且支持切换升级包获取路径。
Showing
6 changed files
with
20 additions
and
3 deletions
Show diff stats
app-api/controllers/UpgradeController.php
... | ... | @@ -177,7 +177,12 @@ class UpgradeController extends BaseController |
177 | 177 | $e->message = '有升级包'; |
178 | 178 | $e->update_flag = $upgradeRecord->focuse; |
179 | 179 | $e->version = $upgradeRecord->version; |
180 | - $e->file_path = $domainURL.$upgradeRecord->path; | |
180 | + // 根据配置文件切换读取更新文件的路径 | |
181 | + if (isset(Yii::$app->params["UPGRADE_FILE_FROM"]) && "FROM_OSS" == Yii::$app->params["UPGRADE_FILE_FROM"]) { | |
182 | + $e->file_path = Yii::$app->params["ossOptions"]["url"] . "/" . $upgradeRecord->path; | |
183 | + } else { | |
184 | + $e->file_path = $domainURL.$upgradeRecord->upload_path; | |
185 | + } | |
181 | 186 | $e->file_md5 = $upgradeRecord->file_md5; |
182 | 187 | $e->size = $upgradeRecord->size; |
183 | 188 | $e->package_type = $upgradeRecord->package_type; | ... | ... |
app-ht/modules/upgrade/controllers/UpgradeController.php
... | ... | @@ -519,7 +519,7 @@ class UpgradeController extends BaseController |
519 | 519 | $hashStr = substr(md5($pathInfo['basename']),8,16); |
520 | 520 | $hashName = time() . $hashStr . '.' .$pathInfo['extension']; |
521 | 521 | $uploadPath = $uploadDir . "/" .$hashName; |
522 | - $savePath = $savePath . "/" . $hashName; | |
522 | + $saveUploadPath = $savePath . "/" . $hashName; | |
523 | 523 | if (!$out = fopen($uploadPath, "wb")) { |
524 | 524 | die('{"jsonrpc" : "2.0", "error" : {"code": 106, "message": "Failed to open output stream."}, "id" : "id"}'); |
525 | 525 | } |
... | ... | @@ -545,6 +545,7 @@ class UpgradeController extends BaseController |
545 | 545 | 'success' => true, |
546 | 546 | 'oldName' => $oldName, |
547 | 547 | 'filePath' => $savePath, |
548 | + 'uploadPath' => $saveUploadPath, | |
548 | 549 | 'fileSize' => filesize($uploadPath), |
549 | 550 | 'fileSuffixes' => $pathInfo['extension'], //文件后缀名 |
550 | 551 | 'file_md5' => md5_file($uploadPath), |
... | ... | @@ -554,7 +555,7 @@ class UpgradeController extends BaseController |
554 | 555 | $fileService = new FileService(); |
555 | 556 | $fileService->add($uploadPath, $savePath); |
556 | 557 | // 删除服务器传成功的文件 |
557 | - @unlink($uploadPath); | |
558 | + //@unlink($uploadPath); | |
558 | 559 | |
559 | 560 | /** |
560 | 561 | * 后台操作日志 | ... | ... |
app-ht/modules/upgrade/views/upgrade/create.php
... | ... | @@ -76,6 +76,7 @@ $this->params['breadcrumbs'][] = $this->title; |
76 | 76 | <label for="package" class="col-sm-4 control-label text-right"><span style="color: #ff0000;">*</span>上传安装包:</label> |
77 | 77 | <input type="hidden" id="type" name="type" value="<?= (isset($gets["type"]) ? $gets["type"] : UpgradeStatus::TYPE_APP) ?>"/> |
78 | 78 | <input type="hidden" id="path" name="path" value="<?= (isset($gets["path"]) ? $gets["path"] : "") ?>"/> |
79 | + <input type="hidden" id="upload_path" name="upload_path" value="<?= (isset($gets["upload_path"]) ? $gets["upload_path"] : "") ?>"/> | |
79 | 80 | <input type="hidden" id="size" name="size" value="<?= (isset($gets["size"]) ? $gets["size"] : "") ?>"/> |
80 | 81 | <input type="hidden" id="file_md5" name="file_md5" value="<?= (isset($gets["file_md5"]) ? $gets["file_md5"] : "") ?>"/> |
81 | 82 | <input type="hidden" id="oldName" name="oldName" value="<?= (isset($gets["oldName"]) ? $gets["oldName"] : "") ?>"/> |
... | ... | @@ -233,6 +234,7 @@ $this->params['breadcrumbs'][] = $this->title; |
233 | 234 | $("#save").removeAttr("disabled"); |
234 | 235 | //$list.append('<input type="hidden" name="'+ids+'" value="'+response.filePath+'" />'); |
235 | 236 | $("input[name='path']").val(response.filePath); |
237 | + $("input[name='upload_path']").val(response.uploadPath); | |
236 | 238 | $("input[name='size']").val(response.fileSize); |
237 | 239 | $("input[name='file_md5']").val(response.file_md5); |
238 | 240 | $("input[name='oldName']").val(response.oldName); |
... | ... | @@ -241,6 +243,7 @@ $this->params['breadcrumbs'][] = $this->title; |
241 | 243 | // 文件上传失败,显示上传出错 |
242 | 244 | uploader.on( 'uploadError', function( file ,response) { |
243 | 245 | $("input[name='path']").val(""); |
246 | + $("input[name='upload_path']").val(""); | |
244 | 247 | $("input[name='size']").val(""); |
245 | 248 | $("input[name='file_md5']").val(""); |
246 | 249 | $("input[name='oldName']").val(""); | ... | ... |
app-ht/modules/upgrade/views/upgrade/edit.php
... | ... | @@ -76,6 +76,7 @@ $this->params['breadcrumbs'][] = $this->title; |
76 | 76 | <input type="hidden" id="type" name="type" value="<?= (isset($info["type"]) ? $info["type"] : UpgradeStatus::TYPE_APP) ?>"/> |
77 | 77 | <input type="hidden" id="uid" name="uid" value="<?= (isset($info["id"]) ? $info["id"] : (isset($info["uid"]) ? $info["uid"] : "")) ?>"/> |
78 | 78 | <input type="hidden" id="path" name="path" value="<?= (isset($info["path"]) ? $info["path"] : "") ?>"/> |
79 | + <input type="hidden" id="upload_path" name="upload_path" value="<?= (isset($info["upload_path"]) ? $info["upload_path"] : "") ?>"/> | |
79 | 80 | <input type="hidden" id="size" name="size" value="<?= (isset($info["size"]) ? $info["size"] : "") ?>"/> |
80 | 81 | <input type="hidden" id="file_md5" name="file_md5" value="<?= (isset($info["file_md5"]) ? $info["file_md5"] : "") ?>"/> |
81 | 82 | <input type="hidden" id="oldName" name="oldName" value="<?= (isset($info["oldName"]) ? $info["oldName"] : "") ?>"/> |
... | ... | @@ -224,6 +225,7 @@ $this->params['breadcrumbs'][] = $this->title; |
224 | 225 | $( '#'+file.id ).find('p.state').text('已上传'); |
225 | 226 | //$list.append('<input type="hidden" name="'+ids+'" value="'+response.filePath+'" />'); |
226 | 227 | $("input[name='path']").val(response.filePath); |
228 | + $("input[name='upload_path']").val(response.uploadPath); | |
227 | 229 | $("input[name='size']").val(response.fileSize); |
228 | 230 | $("input[name='file_md5']").val(response.file_md5); |
229 | 231 | $("input[name='oldName']").val(response.oldName); |
... | ... | @@ -233,6 +235,7 @@ $this->params['breadcrumbs'][] = $this->title; |
233 | 235 | uploader.on( 'uploadError', function( file ) { |
234 | 236 | $("input[name='path']").val(""); |
235 | 237 | $("input[name='size']").val(""); |
238 | + $("input[name='upload_path']").val(""); | |
236 | 239 | $("input[name='file_md5']").val(""); |
237 | 240 | $("input[name='oldName']").val(""); |
238 | 241 | $( '#'+file.id ).find('p.state').text('上传出错'); | ... | ... |
common/config/params.php
domain/upgrade/Upgrade.php
... | ... | @@ -41,6 +41,7 @@ class Upgrade |
41 | 41 | $upgradeModel->model_id = $item["model_id"]; // 型号 |
42 | 42 | $upgradeModel->desc = $item["desc"]; // 描述 |
43 | 43 | $upgradeModel->path = $item["path"]; // 文件路径 |
44 | + $upgradeModel->upload_path = $item["upload_path"]; // 服务器文件路径 | |
44 | 45 | $upgradeModel->package_name = $item["package_name"]; // 安装包名称 |
45 | 46 | if (isset($item["device_ids"])) { |
46 | 47 | $upgradeModel->device_ids = $item["指定deviceID,可以多个,多个用逗号隔开"]; // 版本 |
... | ... | @@ -99,6 +100,9 @@ class Upgrade |
99 | 100 | if (isset($item['path']) && !empty($item['path'])) { |
100 | 101 | $upgradeModel->path = $item['path']; |
101 | 102 | } |
103 | + if (isset($item['upload_path']) && !empty($item['upload_path'])) { | |
104 | + $upgradeModel->upload_path = $item['upload_path']; | |
105 | + } | |
102 | 106 | if (isset($item['focuse']) && !empty($item['focuse'])) { |
103 | 107 | $upgradeModel->focuse = $item['focuse']; |
104 | 108 | } | ... | ... |