Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-admin users not being able to create playlists #524

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading