Skip to content

Commit

Permalink
Remove unneeded directory creation (#3397)
Browse files Browse the repository at this point in the history
This commit removes the directory creation for the 'getMediaLibrary' function.
According to Flysystem, the actual driver creates the required directory when attempting
to write a file.

> When writing files, the directory you’re writing to will be created automatically if and when that is required in the filesystem you’re writing to. If your filesystem does not require directories to exist (like AWS S3), the directory is not created. This is a performance consideration. Of course, you can always create the directory yourself by using the createDirectory operation.
  • Loading branch information
grEvenX authored Oct 24, 2023
1 parent 3b18a86 commit ae3107b
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/MediaCollections/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,6 @@ public function getMediaDirectory(Media $media, ?string $type = null): string
$directory = $pathGenerator->getPathForResponsiveImages($media);
}

$diskDriverName = in_array($type, ['conversions', 'responsiveImages'])
? $media->getConversionsDiskDriverName()
: $media->getDiskDriverName();

$diskName = in_array($type, ['conversions', 'responsiveImages'])
? $media->conversions_disk
: $media->disk;

if (! Str::contains($diskDriverName, ['s3', 'gcs'], true)) {
$this->filesystem->disk($diskName)->makeDirectory($directory);
}

return $directory;
}

Expand Down

0 comments on commit ae3107b

Please sign in to comment.