using filepath.Base(track.FilePath) for fileName

This commit is contained in:
natilou
2023-06-16 11:42:57 -03:00
parent 701001121f
commit b1a266d217
+3 -5
View File
@@ -7,7 +7,7 @@ import (
"io" "io"
"log" "log"
"os" "os"
"strings" "path/filepath"
"time" "time"
"github.com/dweymouth/supersonic/backend" "github.com/dweymouth/supersonic/backend"
@@ -526,8 +526,7 @@ func (c *Controller) ShowDownloadDialog(tracks []*mediaprovider.Track) {
numTracks := len(tracks) numTracks := len(tracks)
var fileName string var fileName string
if numTracks == 1 { if numTracks == 1 {
parts := strings.Split(tracks[0].FilePath, "/") fileName = filepath.Base(tracks[0].FilePath)
fileName = parts[len(parts)-1]
} else { } else {
fileName = "downloaded_tracks.zip" fileName = "downloaded_tracks.zip"
} }
@@ -595,8 +594,7 @@ func (c *Controller) downloadTracks(tracks []*mediaprovider.Track, filePath stri
continue continue
} }
parts := strings.Split(track.FilePath, "/") fileName := filepath.Base(track.FilePath)
fileName := parts[len(parts)-1]
fileWriter, err := zipWriter.Create(fileName) fileWriter, err := zipWriter.Create(fileName)
if err != nil { if err != nil {