@@ -46,6 +46,20 @@ public function performConversions(
46
46
Media $ media ,
47
47
bool $ onlyMissing = false
48
48
): self {
49
+ $ conversions = $ conversions
50
+ ->when (
51
+ $ onlyMissing ,
52
+ fn (ConversionCollection $ conversions ) => $ conversions ->reject (function (Conversion $ conversion ) use ($ media ) {
53
+ $ relativePath = $ media ->getPath ($ conversion ->getName ());
54
+
55
+ if ($ rootPath = config ("filesystems.disks. {$ media ->disk }.root " )) {
56
+ $ relativePath = str_replace ($ rootPath , '' , $ relativePath );
57
+ }
58
+
59
+ return Storage::disk ($ media ->disk )->exists ($ relativePath );
60
+ })
61
+ );
62
+
49
63
if ($ conversions ->isEmpty ()) {
50
64
return $ this ;
51
65
}
@@ -57,19 +71,7 @@ public function performConversions(
57
71
$ temporaryDirectory ->path (Str::random (32 ).'. ' .$ media ->extension )
58
72
);
59
73
60
- $ conversions
61
- ->reject (function (Conversion $ conversion ) use ($ onlyMissing , $ media ) {
62
- $ relativePath = $ media ->getPath ($ conversion ->getName ());
63
-
64
- if ($ rootPath = config ("filesystems.disks. {$ media ->disk }.root " )) {
65
- $ relativePath = str_replace ($ rootPath , '' , $ relativePath );
66
- }
67
-
68
- return $ onlyMissing && Storage::disk ($ media ->disk )->exists ($ relativePath );
69
- })
70
- ->each (function (Conversion $ conversion ) use ($ media , $ copiedOriginalFile ) {
71
- (new PerformConversionAction )->execute ($ conversion , $ media , $ copiedOriginalFile );
72
- });
74
+ $ conversions ->each (fn (Conversion $ conversion ) => (new PerformConversionAction )->execute ($ conversion , $ media , $ copiedOriginalFile ));
73
75
74
76
$ temporaryDirectory ->delete ();
75
77
0 commit comments