Skip to content

Commit

Permalink
fix(playlist): fix non-admin users not being able to create playlists (
Browse files Browse the repository at this point in the history
…#524)

* fix(playlist): fail early if playlist path is a directory

* fix(playlist): check error before assuming playlist loaded
  • Loading branch information
roobre authored Sep 15, 2024
1 parent bcb613c commit ac798ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions playlist/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ func (s *Store) Read(relPath string) (*Playlist, error) {
return nil, fmt.Errorf("stat m3u: %w", err)
}

if stat.IsDir() {
return nil, errors.New("path is a directory")
}

var playlist Playlist
playlist.UpdatedAt = stat.ModTime()

Expand Down
6 changes: 4 additions & 2 deletions server/ctrlsubsonic/handlers_playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ func (c *Controller) ServeCreateOrUpdatePlaylist(r *http.Request) *spec.Response
playlistPath := playlistIDDecode(playlistID)

var playlist playlistp.Playlist
if pl, _ := c.playlistStore.Read(playlistPath); pl != nil {
playlist = *pl
if playlistPath != "" {
if pl, err := c.playlistStore.Read(playlistPath); err != nil && pl != nil {
playlist = *pl
}
}

if playlist.UserID != 0 && playlist.UserID != user.ID {
Expand Down

0 comments on commit ac798ac

Please sign in to comment.