Skip to content

Commit

Permalink
finalize feature and fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
0chroma committed Sep 7, 2024
1 parent 4316237 commit c77ca29
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions playlist/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io/fs"
"log"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -129,10 +130,11 @@ func (s *Store) Read(relPath string) (*Playlist, error) {
continue
}

//file path might be relative if using playlists-relative
//file path might be relative if using -playlists-relative

Check failure on line 133 in playlist/playlist.go

View workflow job for this annotation

GitHub Actions / Lint and test

commentFormatting: put a space between `//` and comment text (gocritic)
if !filepath.IsAbs(line) {
line = filepath.Join(filepath.Dir(absPath), line)
}

playlist.Items = append(playlist.Items, line)
}

Expand Down Expand Up @@ -185,13 +187,16 @@ func (s *Store) Write(relPath string, playlist *Playlist) error {
fmt.Fprintln(file, encodeAttr(attrCommment, playlist.Comment))
fmt.Fprintln(file, encodeAttr(attrIsPublic, fmt.Sprint(playlist.IsPublic)))
for _, line := range playlist.Items {
//transform to path relative to basePath
relativePath, err := filepath.Rel(filepath.Dir(absPath), line)
if s.relative && err != nil {
fmt.Fprintln(file, relativePath)
} else {
fmt.Fprintln(file, line)
if s.relative {
//transform to path relative to playlist's dir

Check failure on line 191 in playlist/playlist.go

View workflow job for this annotation

GitHub Actions / Lint and test

commentFormatting: put a space between `//` and comment text (gocritic)
relativePath, err := filepath.Rel(filepath.Dir(absPath), line)
if err == nil {
line = relativePath
} else {
log.Printf("Warning: could not make playlist entry path's relative - %v\n", err)
}
}
fmt.Fprintln(file, line)
}
return nil
}
Expand Down

0 comments on commit c77ca29

Please sign in to comment.