A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
chore: code smells
aminnausin353d0d96612e
diff --git a/app/Services/Images/ImageService.php b/app/Services/Images/ImageService.phpindex 24fca1bc..640858a1 100644--- a/app/Services/Images/ImageService.php+++ b/app/Services/Images/ImageService.php@@ -226,12 +226,7 @@ class ImageService {try {if (! $file->isValid()) {- Log::warning(- 'Uploaded image invalid',- $debugInfo- );-- return null;+ throw new InvalidImageDataException('Uploaded image invalid');}$fmt = match ($file->getMimeType()) {@@ -246,9 +241,7 @@ class ImageService {Storage::disk('public')->putFileAs(dirname($relativeOutputPath), $file, basename($relativeOutputPath));if (! file_exists($absoluteOutputPath) || filesize($absoluteOutputPath) === 0) {- Log::warning('Failed to upload image, file missing', [...$debugInfo, 'outputPath' => $absoluteOutputPath]);-- return null;+ throw new InvalidImageDataException('Failed to upload image, file missing', ['outputPath' => $absoluteOutputPath]);}return $this->persistImage(@@ -262,6 +255,10 @@ class ImageService {userId: $userId,));+ } catch (InvalidImageDataException $th) {+ Log::warning('Failed to upload image', [...$debugInfo, 'error' => $th->getMessage(), ...$th->getContext()]);++ return null;} catch (\Throwable $th) {Log::warning('Failed to upload image', [...$debugInfo, 'error' => $th->getMessage()]);diff --git a/resources/js/components/cedar-ui/form/FormErrorList.vue b/resources/js/components/cedar-ui/form/FormErrorList.vueindex e293b185..764fc790 100644--- a/resources/js/components/cedar-ui/form/FormErrorList.vue+++ b/resources/js/components/cedar-ui/form/FormErrorList.vue@@ -10,7 +10,7 @@ const getErrorList = (errors: Record<string, any>, fieldName?: string): string[]const { message, ...rest } = errors;- return [...Object.values(rest).flat()].filter(Boolean);+ return Object.values(rest).flat().filter(Boolean);} catch (error) {console.error(error);return [];diff --git a/resources/js/components/forms/EditImages.vue b/resources/js/components/forms/EditImages.vueindex ca0474a9..7b7f7cbb 100644--- a/resources/js/components/forms/EditImages.vue+++ b/resources/js/components/forms/EditImages.vue@@ -152,7 +152,7 @@ function handleUrlFetch() {const url = new URL(urlInput.value.trim());if (!['http:', 'https:'].includes(url.protocol)) {- throw new Error();+ throw new Error('Invalid URL');}form.fields.image_id = addUrl(url.toString(), filteredType.value).tempId;@@ -161,7 +161,8 @@ function handleUrlFetch() {form.clearErrors();urlInput.value = '';} catch (error) {- toast.error('Error', { description: 'Invalid URL' });+ console.error(error);+ toast.error('Error', { description: error?.toString() ?? 'Invalid URL' });urlInput.value = '';}}@@ -211,7 +212,7 @@ function placeCursorAtEnd() {if (!mobileUrlInput.value) return;const range = document.createRange();- const selection = window.getSelection();+ const selection = globalThis.getSelection();range.selectNodeContents(mobileUrlInput.value);range.collapse(false);@@ -248,7 +249,7 @@ watch(filteredType, (type) => {onMounted(() => {document.addEventListener('paste', handlePaste);- isMobile.value = window.matchMedia('(pointer: coarse)').matches;+ isMobile.value = globalThis.matchMedia('(pointer: coarse)').matches;});onUnmounted(() => {