playlist/Length: throw PlaylistError::NoSuchList instead of returning false
This commit is contained in:
parent
c974fc664c
commit
a5456a89dc
|
@ -164,11 +164,8 @@ handle_playlistlength(Client &client, Request args, Response &r)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
if (playlist_file_length(r, client.GetPartition(), SongLoader(client),
|
playlist_file_length(r, client.GetPartition(), SongLoader(client), name);
|
||||||
name))
|
return CommandResult::OK;
|
||||||
return CommandResult::OK;
|
|
||||||
|
|
||||||
throw PlaylistError::NoSuchList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult
|
CommandResult
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "thread/Mutex.hxx"
|
#include "thread/Mutex.hxx"
|
||||||
#include "Partition.hxx"
|
#include "Partition.hxx"
|
||||||
#include "Instance.hxx"
|
#include "Instance.hxx"
|
||||||
|
#include "PlaylistError.hxx"
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
@ -45,10 +46,10 @@ playlist_provider_length(Response &r,
|
||||||
r.Fmt(FMT_STRING("playtime: {}\n"), playtime.RoundS());
|
r.Fmt(FMT_STRING("playtime: {}\n"), playtime.RoundS());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
playlist_file_length(Response &r, Partition &partition,
|
playlist_file_length(Response &r, Partition &partition,
|
||||||
const SongLoader &loader,
|
const SongLoader &loader,
|
||||||
const LocatedUri &uri)
|
const LocatedUri &uri)
|
||||||
{
|
{
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
|
|
||||||
|
@ -62,8 +63,7 @@ playlist_file_length(Response &r, Partition &partition,
|
||||||
#endif
|
#endif
|
||||||
mutex);
|
mutex);
|
||||||
if (playlist == nullptr)
|
if (playlist == nullptr)
|
||||||
return false;
|
throw PlaylistError::NoSuchList();
|
||||||
|
|
||||||
playlist_provider_length(r, loader, uri.canonical_uri, *playlist);
|
playlist_provider_length(r, loader, uri.canonical_uri, *playlist);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
// Copyright The Music Player Daemon Project
|
// Copyright The Music Player Daemon Project
|
||||||
|
|
||||||
#ifndef MPD_PLAYLIST__LENGTH_HXX
|
#pragma once
|
||||||
#define MPD_PLAYLIST__LENGTH_HXX
|
|
||||||
|
|
||||||
#include "client/Response.hxx"
|
#include "client/Response.hxx"
|
||||||
|
|
||||||
|
@ -13,12 +12,12 @@ struct Partition;
|
||||||
* Count the number of songs and their total playtime (seconds) in the
|
* Count the number of songs and their total playtime (seconds) in the
|
||||||
* playlist.
|
* playlist.
|
||||||
*
|
*
|
||||||
|
* Throws on error.
|
||||||
|
*
|
||||||
* @param uri the URI of the playlist file in UTF-8 encoding
|
* @param uri the URI of the playlist file in UTF-8 encoding
|
||||||
* @return true on success, false if the playlist does not exist
|
* @return true on success, false if the playlist does not exist
|
||||||
*/
|
*/
|
||||||
bool
|
void
|
||||||
playlist_file_length(Response &r, Partition &partition,
|
playlist_file_length(Response &r, Partition &partition,
|
||||||
const SongLoader &loader,
|
const SongLoader &loader,
|
||||||
const LocatedUri &uri);
|
const LocatedUri &uri);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue