mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-30 14:09:58 +08:00
Inline one-time used helper function
This commit is contained in:
parent
aa30d5a41e
commit
634f0b726a
@ -199,10 +199,16 @@ class SkinlibController extends Controller
|
||||
return $response;
|
||||
}
|
||||
|
||||
$file = $request->file('file');
|
||||
$responses = event(new \App\Events\HashingFile($file));
|
||||
if (isset($responses[0]) && is_string($responses[0])) {
|
||||
return $responses[0]; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$t = new Texture();
|
||||
$t->name = $request->input('name');
|
||||
$t->type = $request->input('type');
|
||||
$t->hash = bs_hash_file($request->file('file'));
|
||||
$t->hash = hash_file('sha256', $file);
|
||||
$t->size = ceil($request->file('file')->getSize() / 1024);
|
||||
$t->public = $request->input('public') == 'true';
|
||||
$t->uploader = $user->uid;
|
||||
|
@ -85,20 +85,6 @@ if (! function_exists('json')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('bs_hash_file')) {
|
||||
function bs_hash_file(Illuminate\Http\UploadedFile $file)
|
||||
{
|
||||
// Try to get hash from event listener
|
||||
$responses = event(new App\Events\HashingFile($file));
|
||||
if (isset($responses[0]) && is_string($responses[0])) {
|
||||
return $responses[0];
|
||||
}
|
||||
|
||||
// Default to sha256 hash
|
||||
return hash_file('sha256', $file);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('bs_footer_extra')) {
|
||||
function bs_footer_extra()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user