Inline one-time used helper function

This commit is contained in:
Pig Fang 2019-04-04 11:16:04 +08:00
parent aa30d5a41e
commit 634f0b726a
2 changed files with 7 additions and 15 deletions

View File

@ -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;

View File

@ -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()
{