fix checking file exists
This commit is contained in:
parent
0fe1391750
commit
35c978697b
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use Storage;
|
||||||
use App\Models\Texture;
|
use App\Models\Texture;
|
||||||
use App\Events\GetAvatarPreview;
|
use App\Events\GetAvatarPreview;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
@ -23,12 +24,12 @@ class CacheAvatarPreview
|
||||||
|
|
||||||
$path = BASE_DIR."/storage/textures/$hash";
|
$path = BASE_DIR."/storage/textures/$hash";
|
||||||
|
|
||||||
if (!\Storage::disk('cache')->has("avatar/$tid-$size")) {
|
if (!Storage::disk('cache')->has("avatar/$tid-$size")) {
|
||||||
$png = \Minecraft::generateAvatarFromSkin($path, $event->size);
|
$png = \Minecraft::generateAvatarFromSkin($path, $event->size);
|
||||||
imagepng($png, BASE_DIR."/storage/cache/avatar/$tid-$size");
|
imagepng($png, BASE_DIR."/storage/cache/avatar/$tid-$size");
|
||||||
imagedestroy($png);
|
imagedestroy($png);
|
||||||
}
|
}
|
||||||
|
|
||||||
return \Response::png(\Storage::disk('cache')->get("avatar/$tid-$size"));
|
return \Response::png(Storage::disk('cache')->get("avatar/$tid-$size"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use Storage;
|
||||||
use App\Models\PlayerModel;
|
use App\Models\PlayerModel;
|
||||||
use App\Events\CheckPlayerExists;
|
use App\Events\CheckPlayerExists;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
@ -19,9 +20,9 @@ class CachePlayerExists
|
||||||
{
|
{
|
||||||
$player_name = $event->player_name;
|
$player_name = $event->player_name;
|
||||||
|
|
||||||
if (!\Storage::disk('cache')->has("notfound/$player_name")) {
|
if ($player_name && !Storage::disk('cache')->has("notfound/$player_name")) {
|
||||||
if (PlayerModel::where('player_name', $player_name)->get()->isEmpty()) {
|
if (PlayerModel::where('player_name', $player_name)->get()->isEmpty()) {
|
||||||
\Storage::disk('cache')->put("notfound/$player_name", '');
|
Storage::disk('cache')->put("notfound/$player_name", '');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
abort(404, '角色不存在');
|
abort(404, '角色不存在');
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,6 @@ class CachePlayerJson
|
||||||
Storage::disk('cache')->put($filename, $player->generateJsonProfile($api_type));
|
Storage::disk('cache')->put($filename, $player->generateJsonProfile($api_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return \Storage::disk('cache')->get($filename);
|
return Storage::disk('cache')->get($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use Storage;
|
||||||
use App\Events\PlayerWasAdded;
|
use App\Events\PlayerWasAdded;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
@ -18,8 +19,8 @@ class FreshNotFoundCache
|
||||||
{
|
{
|
||||||
$player_name = $event->player->player_name;
|
$player_name = $event->player->player_name;
|
||||||
|
|
||||||
if (\Storage::disk('cache')->has("notfound/$player_name")) {
|
if ($player_name && Storage::disk('cache')->has("notfound/$player_name")) {
|
||||||
\Storage::disk('cache')->delete("notfound/$player_name", '');
|
Storage::disk('cache')->delete("notfound/$player_name", '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user