Fix the problem of deleting attachment on USS but failed (#2607)

#### What type of PR is this?

/kind bug
/area core
/milestone 1.6.x

#### What this PR does / why we need it:

修复又拍云附件删除成功,但是管理页面的“internal server error” 报警

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2603

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
修复又拍云附件删除成功仍旧提示错误的问题
```
pull/5661/head
shiker 2022-10-23 22:18:10 +08:00 committed by GitHub
parent 075d780ade
commit d43190d74c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -138,11 +138,12 @@ public class UpOssFileHandler implements FileHandler {
try {
Response result = manager.deleteFile(key, null);
HashMap respondBody = JsonUtils.jsonToObject(result.body().string(), HashMap.class);
if (!result.isSuccessful()
&& !(result.code() == 404 && respondBody.get("code").equals(40400001))) {
log.warn("附件 " + key + " 从又拍云删除失败");
throw new FileOperationException("附件 " + key + " 从又拍云删除失败");
if (result.code() != 200) {
HashMap respondBody = JsonUtils.jsonToObject(result.body().string(), HashMap.class);
if (!(result.code() == 404 && respondBody.get("code").equals(40400001))) {
log.warn("附件 " + key + " 从又拍云删除失败");
throw new FileOperationException("附件 " + key + " 从又拍云删除失败");
}
}
} catch (IOException | UpException e) {
e.printStackTrace();