From b1a266d217591f1e945047a5840c03b303ed81e8 Mon Sep 17 00:00:00 2001 From: natilou <30585029+natilou@users.noreply.github.com> Date: Fri, 16 Jun 2023 11:40:11 -0300 Subject: [PATCH] using filepath.Base(track.FilePath) for fileName --- ui/controller/controller.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ui/controller/controller.go b/ui/controller/controller.go index f382f3d..fd57e9d 100644 --- a/ui/controller/controller.go +++ b/ui/controller/controller.go @@ -7,7 +7,7 @@ import ( "io" "log" "os" - "strings" + "path/filepath" "time" "github.com/dweymouth/supersonic/backend" @@ -526,8 +526,7 @@ func (c *Controller) ShowDownloadDialog(tracks []*mediaprovider.Track) { numTracks := len(tracks) var fileName string if numTracks == 1 { - parts := strings.Split(tracks[0].FilePath, "/") - fileName = parts[len(parts)-1] + fileName = filepath.Base(tracks[0].FilePath) } else { fileName = "downloaded_tracks.zip" } @@ -595,8 +594,7 @@ func (c *Controller) downloadTracks(tracks []*mediaprovider.Track, filePath stri continue } - parts := strings.Split(track.FilePath, "/") - fileName := parts[len(parts)-1] + fileName := filepath.Base(track.FilePath) fileWriter, err := zipWriter.Create(fileName) if err != nil {