Commit 1a1324626558259ced5c047e4479045c5ad7d917

Authored by xu
1 parent b5b47ff1
Exists in master

domain

1. F 删除版本的时候也删除上传的文件,本地和OSS都一起删除
Showing 1 changed file with 9 additions and 1 deletions   Show diff stats
domain/upgrade/Upgrade.php
... ... @@ -4,6 +4,7 @@ namespace domain\upgrade;
4 4  
5 5 use Yii;
6 6 use domain\upgrade\models\Upgrade as UpgradeModel;
  7 +use Resource\FileService;
7 8 use Exception;
8 9  
9 10 /**
... ... @@ -159,7 +160,14 @@ class Upgrade
159 160 if (empty($upgradeModel)) {
160 161 return false;
161 162 }
  163 + $path = $upgradeModel->path;
  164 + $uploadPath = $upgradeModel->upload_path;
  165 + $localRoot = Yii::getAlias('@app/ht');
  166 + unlink($localRoot.'/'.$uploadPath);
  167 + $fileService = new FileService();
  168 + $fileService->delete($path);
162 169  
163   - return UpgradeModel::updateAll(["is_delete" => 1], ["id" => $id]);
  170 +
  171 + return UpgradeModel::updateAll(["is_delete" => 1, 'path' => null, 'upload_path' => null], ["id" => $id]);
164 172 }
165 173 }
166 174 \ No newline at end of file
... ...