diff --git a/app/Jobs/MediaWorkerJob.php b/app/Jobs/MediaWorkerJob.php index 7cf4623..e79ad7e 100644 --- a/app/Jobs/MediaWorkerJob.php +++ b/app/Jobs/MediaWorkerJob.php @@ -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([ diff --git a/resources/js/components/SMDialog.ts b/resources/js/components/SMDialog.ts index c8fcc88..3af256a 100644 --- a/resources/js/components/SMDialog.ts +++ b/resources/js/components/SMDialog.ts @@ -5,6 +5,7 @@ import { defineComponent, shallowReactive, VNodeProps, + watch, } from "vue"; export interface DialogInstance { @@ -52,10 +53,10 @@ export function closeDialog(data?: unknown) { } const lastDialog = dialogRefs.pop(); - if (data === undefined && lastDialog.comp) { + if (data === undefined && lastDialog.comp && lastDialog.comp.returnValue) { data = lastDialog.comp.returnValue(); } - if (lastDialog) { + if (lastDialog && data !== undefined) { lastDialog.resolve(data); } } @@ -112,7 +113,9 @@ export function openDialog( }); window.setTimeout(() => { - const autofocusElement = document.querySelector("[autofocus]"); + const autofocusElement = document.querySelector( + "[autofocus]", + ) as HTMLInputElement; if (autofocusElement) { autofocusElement.focus(); } diff --git a/resources/js/components/SMSelectFile.vue b/resources/js/components/SMSelectFile.vue index d9c9eed..6f24b23 100644 --- a/resources/js/components/SMSelectFile.vue +++ b/resources/js/components/SMSelectFile.vue @@ -13,7 +13,17 @@ fill="currentColor" />
+

+ {{ feedbackInvalid }} +