From ffd4daf031cc896d1dfd8c7b611365f3b7d61446 Mon Sep 17 00:00:00 2001 From: enriqueqs <55209162+enriqueqs@users.noreply.github.com> Date: Fri, 12 Dec 2025 11:31:13 +0100 Subject: [PATCH] fixed path issue (#157) Co-authored-by: afkarxyz --- backend/filename.go | 2 +- frontend/src/components/Settings.tsx | 8 +++----- frontend/src/hooks/useDownload.ts | 10 +++++++--- frontend/src/lib/utils.ts | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/backend/filename.go b/backend/filename.go index d5b5b28..1fd5342 100644 --- a/backend/filename.go +++ b/backend/filename.go @@ -80,7 +80,7 @@ func SanitizeFolderPath(folderPath string) string { continue } - // Keep empty string at the start for absolute paths on Unix + // Keep empty first part for absolute paths on Unix (e.g., "/Users/...") if i == 0 && part == "" { sanitizedParts = append(sanitizedParts, part) continue diff --git a/frontend/src/components/Settings.tsx b/frontend/src/components/Settings.tsx index 2946878..5101547 100644 --- a/frontend/src/components/Settings.tsx +++ b/frontend/src/components/Settings.tsx @@ -130,7 +130,8 @@ export function Settings() { if (open) { setTempSettings(savedSettings); } - }, [open, savedSettings]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [open]); const handleSave = () => { saveSettings(tempSettings); @@ -187,12 +188,9 @@ export function Settings() { try { // Call backend to open folder selection dialog const selectedPath = await SelectFolder(tempSettings.downloadPath || ""); - console.log("Selected path:", selectedPath); - + if (selectedPath && selectedPath.trim() !== "") { setTempSettings((prev) => ({ ...prev, downloadPath: selectedPath })); - } else { - console.log("No folder selected or user cancelled"); } } catch (error) { console.error("Error selecting folder:", error); diff --git a/frontend/src/hooks/useDownload.ts b/frontend/src/hooks/useDownload.ts index bead09d..6074d47 100644 --- a/frontend/src/hooks/useDownload.ts +++ b/frontend/src/hooks/useDownload.ts @@ -22,6 +22,7 @@ export function useDownload() { const downloadWithAutoFallback = async ( isrc: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any settings: any, trackName?: string, artistName?: string, @@ -32,7 +33,7 @@ export function useDownload() { durationMs?: number, releaseYear?: string ) => { - let service = settings.downloader; + const service = settings.downloader; const query = trackName && artistName ? `${trackName} ${artistName}` : undefined; const os = settings.operatingSystem; @@ -65,7 +66,7 @@ export function useDownload() { outputDir = joinPath(os, outputDir, sanitizePath(part, os)); } } - + // Use album track number if template contains {album} if (settings.folderTemplate.includes("{album}")) { useAlbumTrackNumber = true; @@ -78,6 +79,7 @@ export function useDownload() { if (service === "auto") { // Get all streaming URLs once from song.link API + // eslint-disable-next-line @typescript-eslint/no-explicit-any let streamingURLs: any = null; if (spotifyId) { try { @@ -246,6 +248,7 @@ export function useDownload() { const downloadWithItemID = async ( isrc: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any settings: any, itemID: string, trackName?: string, @@ -258,7 +261,7 @@ export function useDownload() { isAlbum?: boolean, releaseYear?: string ) => { - let service = settings.downloader; + const service = settings.downloader; const query = trackName && artistName ? `${trackName} ${artistName}` : undefined; const os = settings.operatingSystem; @@ -302,6 +305,7 @@ export function useDownload() { if (service === "auto") { // Get all streaming URLs once from song.link API + // eslint-disable-next-line @typescript-eslint/no-explicit-any let streamingURLs: any = null; if (spotifyId) { try { diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index d9e842a..7cb62ce 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -19,10 +19,10 @@ export function sanitizePath(input: string, os: string): string { export function joinPath(os: string, ...parts: string[]): string { const sep = os === "Windows" ? "\\" : "/"; - + const filtered = parts.filter(Boolean); if (filtered.length === 0) return ""; - + const joined = filtered .map((p, i) => { // For first part, only remove trailing slashes (preserve leading slash for absolute paths) @@ -34,7 +34,7 @@ export function joinPath(os: string, ...parts: string[]): string { }) .filter(Boolean) // Remove empty strings after trimming .join(sep); - + return joined; }