From e2281441598bc8205987857d388b7640aa7ea4d0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 13 Apr 2016 19:47:41 +0200 Subject: [PATCH] command/playlist: eliminate spl_print() calls playlist_file_print() already handles stored playlists. spl_print() is never called with a successful result. --- src/PlaylistPrint.cxx | 43 -------------------------------- src/PlaylistPrint.hxx | 11 -------- src/command/PlaylistCommands.cxx | 10 +++----- 3 files changed, 4 insertions(+), 60 deletions(-) diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx index ccab06527..77df82534 100644 --- a/src/PlaylistPrint.cxx +++ b/src/PlaylistPrint.cxx @@ -115,46 +115,3 @@ playlist_print_changes_position(Response &r, queue_print_changes_position(r, playlist.queue, version, start, end); } - -#ifdef ENABLE_DATABASE - -static bool -PrintSongDetails(Response &r, Partition &partition, const char *uri_utf8) -{ - const Database *db = partition.instance.database; - if (db == nullptr) - return false; - - const LightSong *song; - try { - song = db->GetSong(uri_utf8); - } catch (const std::runtime_error &e) { - return false; - } - - song_print_info(r, partition, *song); - db->ReturnSong(song); - return true; -} - -#endif - -void -spl_print(Response &r, Partition &partition, - const char *name_utf8, bool detail) -{ -#ifndef ENABLE_DATABASE - (void)partition; - (void)detail; -#endif - - PlaylistFileContents contents = LoadPlaylistFile(name_utf8); - - for (const auto &uri_utf8 : contents) { -#ifdef ENABLE_DATABASE - if (!detail || !PrintSongDetails(r, partition, - uri_utf8.c_str())) -#endif - r.Format(SONG_FILE "%s\n", uri_utf8.c_str()); - } -} diff --git a/src/PlaylistPrint.hxx b/src/PlaylistPrint.hxx index b61ca7c04..2fc70cdf0 100644 --- a/src/PlaylistPrint.hxx +++ b/src/PlaylistPrint.hxx @@ -91,15 +91,4 @@ playlist_print_changes_position(Response &r, uint32_t version, unsigned start, unsigned end); -/** - * Send the stored playlist to the client. - * - * @param client the client which requested the playlist - * @param name_utf8 the name of the stored playlist in UTF-8 encoding - * @param detail true if all details should be printed - */ -void -spl_print(Response &r, Partition &partition, - const char *name_utf8, bool detail); - #endif diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx index d7a0bbcdb..823fc534a 100644 --- a/src/command/PlaylistCommands.cxx +++ b/src/command/PlaylistCommands.cxx @@ -22,9 +22,9 @@ #include "Request.hxx" #include "db/DatabasePlaylist.hxx" #include "CommandError.hxx" -#include "PlaylistPrint.hxx" #include "PlaylistSave.hxx" #include "PlaylistFile.hxx" +#include "PlaylistError.hxx" #include "db/PlaylistVector.hxx" #include "SongLoader.hxx" #include "BulkEdit.hxx" @@ -85,11 +85,10 @@ handle_listplaylist(Client &client, Request args, Response &r) const char *const name = args.front(); if (playlist_file_print(r, client.partition, SongLoader(client), - name, false)) + name, false)) return CommandResult::OK; - spl_print(r, client.partition, name, false); - return CommandResult::OK; + throw PlaylistError::NoSuchList(); } CommandResult @@ -101,8 +100,7 @@ handle_listplaylistinfo(Client &client, Request args, Response &r) name, true)) return CommandResult::OK; - spl_print(r, client.partition, name, true); - return CommandResult::OK; + throw PlaylistError::NoSuchList(); } CommandResult