command/playlist: eliminate spl_print() calls

playlist_file_print() already handles stored playlists.  spl_print()
is never called with a successful result.
This commit is contained in:
Max Kellermann 2016-04-13 19:47:41 +02:00
parent 9431a7b022
commit e228144159
3 changed files with 4 additions and 60 deletions

View File

@ -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());
}
}

View File

@ -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

View File

@ -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