dont generate variants if it already exists
This commit is contained in:
@@ -206,7 +206,8 @@ class MediaController extends Controller
|
|||||||
$hash = hash_file('sha256', $file->path());
|
$hash = hash_file('sha256', $file->path());
|
||||||
|
|
||||||
$storage = Storage::disk('media');
|
$storage = Storage::disk('media');
|
||||||
if(!$storage->exists($hash)) {
|
$exists = $storage->exists($hash);
|
||||||
|
if(!$exists) {
|
||||||
if($file->storeAs('/', $hash, 'media') === false) {
|
if($file->storeAs('/', $hash, 'media') === false) {
|
||||||
if($request->wantsJson()) {
|
if($request->wantsJson()) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -230,7 +231,10 @@ class MediaController extends Controller
|
|||||||
'hash' => $hash
|
'hash' => $hash
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if(!$exists) {
|
||||||
$media->generateVariants(false);
|
$media->generateVariants(false);
|
||||||
|
}
|
||||||
|
|
||||||
unlink($file->getRealPath());
|
unlink($file->getRealPath());
|
||||||
|
|
||||||
if($request->wantsJson()) {
|
if($request->wantsJson()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user