new media job support

This commit is contained in:
2023-09-01 12:22:25 +10:00
parent fcf5400f71
commit 41ae64a8c9
8 changed files with 362 additions and 638 deletions

View File

@@ -104,12 +104,25 @@ class MediaWorkerJob implements ShouldQueue
}
// Check if file already exists
if (Storage::disk($storage)->exists($data['name']) === true) {
if (array_key_exists('replace', $data) === false || isTrue($data['replace']) === false) {
$exists = Storage::disk($storage)->exists($data['name']);
if ($exists === true) {
if (array_key_exists('noreplace', $data) === true && isTrue($data['noreplace']) === true) {
$this->throwMediaJobFailure('file already exists on server');
}
}
if($exists === true) {
$pathInfo = pathinfo($data['name']);
$basename = $pathInfo['filename'];
$extension = $pathInfo['extension'];
$index = 0;
do {
$index++;
$data['name'] = $basename . '-' . $index . '.' . $extension;
} while (Storage::disk($storage)->exists($data['name']) === true);
}
if ($media === null) {
$newMedia = true;
$media = new Media([