fix missing alert when uploading duplicated texture

(fix #132)
This commit is contained in:
Pig Fang 2020-02-23 09:37:10 +08:00
parent 73d83bd191
commit bec33650f0
4 changed files with 8 additions and 11 deletions

View File

@ -246,16 +246,11 @@ class SkinlibController extends Controller
return json(trans('skinlib.upload.lack-score'), 7); return json(trans('skinlib.upload.lack-score'), 7);
} }
$results = Texture::where('hash', $t->hash)->get(); $repeated = Texture::where('hash', $t->hash)->where('public', true)->first();
if ($repeated) {
if (!$results->isEmpty()) { // if the texture already uploaded was set to private,
foreach ($results as $result) { // then allow to re-upload it.
// if the texture already uploaded was set to private, return json(trans('skinlib.upload.repeated'), 2, ['tid' => $repeated->tid]);
// then allow to re-upload it.
if ($result->public) {
return json(trans('skinlib.upload.repeated'), 0, ['tid' => $result->tid]);
}
}
} }
if (Storage::disk('textures')->missing($t->hash)) { if (Storage::disk('textures')->missing($t->hash)) {

View File

@ -57,6 +57,7 @@
- Fixed that `lang` attribute of HTML can't be configured correctly. - Fixed that `lang` attribute of HTML can't be configured correctly.
- Fixed that avatar can't be resized when requesting an non-existed user. - Fixed that avatar can't be resized when requesting an non-existed user.
- Fixed that the same texture files with different models were treated as different textures. - Fixed that the same texture files with different models were treated as different textures.
- Fixed when uploading duplicated texture, alert is missing.
## Removed ## Removed

View File

@ -57,6 +57,7 @@
- 修复未能正确设置 HTML 的 `lang` 属性的问题 - 修复未能正确设置 HTML 的 `lang` 属性的问题
- 修复获取不存在的用户的头像时,未能正确设置尺寸的问题 - 修复获取不存在的用户的头像时,未能正确设置尺寸的问题
- 修复同一材质文件但模型不同被认为不同材质的问题 - 修复同一材质文件但模型不同被认为不同材质的问题
- 修复上传重复材质时没有提示用户的问题
## 移除 ## 移除

View File

@ -583,7 +583,7 @@ class SkinlibControllerTest extends TestCase
'file' => $upload, 'file' => $upload,
] ]
)->assertJson([ )->assertJson([
'code' => 0, 'code' => 2,
'message' => trans('skinlib.upload.repeated'), 'message' => trans('skinlib.upload.repeated'),
'data' => ['tid' => $t->tid], 'data' => ['tid' => $t->tid],
]); ]);