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

Add config option to disable the listing of playlists in the root folder for the lsinfo command. #2102

Closed
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
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ ver 0.24 (not yet released)
* require libfmt 9 or later
* documentation: switch to sphinx-rtd-theme
* require Meson 1.0
* option to disable listing of playlists with lsinfo in the root folder

ver 0.23.15 (2023/12/20)
* decoder
Expand Down
4 changes: 4 additions & 0 deletions doc/mpd.conf.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ save_absolute_paths_in_playlists <yes or no>
This specifies whether relative or absolute paths for song filenames are used
when saving playlists. The default is "no".

list_playlists_in_root <yes or no>
This specifies whether the lsinfo command should list playlists for the root
folder.

auto_update <yes or no>
This specifies the whether to support automatic update of music database
when files are changed in music_directory. The default is to disable
Expand Down
3 changes: 2 additions & 1 deletion doc/protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,8 @@ The music database

When listing the root directory, this currently returns
the list of stored playlists. This behavior is
deprecated; use "listplaylists" instead.
deprecated; use "listplaylists" instead. This behavior can be
disabled with the config option ``list_playlists_in_root``.

This command may be used to list metadata of remote
files (e.g. URI beginning with "http://" or "smb://").
Expand Down
5 changes: 5 additions & 0 deletions src/PlaylistFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static const char PLAYLIST_COMMENT = '#';

static unsigned playlist_max_length;
bool playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
bool list_playlists_in_root = DEFAULT_LIST_PLAYLISTS_IN_ROOT;

void
spl_global_init(const ConfigData &config)
Expand All @@ -46,6 +47,10 @@ spl_global_init(const ConfigData &config)
playlist_saveAbsolutePaths =
config.GetBool(ConfigOption::SAVE_ABSOLUTE_PATHS,
DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS);

list_playlists_in_root =
config.GetBool(ConfigOption::LIST_PLAYLISTS_IN_ROOT,
DEFAULT_LIST_PLAYLISTS_IN_ROOT);
}

bool
Expand Down
1 change: 1 addition & 0 deletions src/PlaylistFile.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PlaylistVector;
typedef std::vector<std::string> PlaylistFileContents;

extern bool playlist_saveAbsolutePaths;
extern bool list_playlists_in_root;

class PlaylistFileEditor {
const AllocatedPath path;
Expand Down
3 changes: 2 additions & 1 deletion src/command/OtherCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ handle_lsinfo_relative(Client &client, Response &r, const char *uri)
(void)client;
#endif

if (isRootDirectory(uri)) {
if ( list_playlists_in_root &&
isRootDirectory(uri)) {
try {
print_spl_list(r, ListPlaylistFiles());
} catch (...) {
Expand Down
1 change: 1 addition & 0 deletions src/config/Defaults.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
#define MPD_CONFIG_DEFAULTS_HXX

static constexpr bool DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS = false;
static constexpr bool DEFAULT_LIST_PLAYLISTS_IN_ROOT = true;

#endif
1 change: 1 addition & 0 deletions src/config/Option.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum class ConfigOption {
AUTO_UPDATE_DEPTH,

MIXRAMP_ANALYZER,
LIST_PLAYLISTS_IN_ROOT,

MAX
};
Expand Down
1 change: 1 addition & 0 deletions src/config/Templates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const ConfigTemplate config_param_templates[] = {
{ "auto_update" },
{ "auto_update_depth" },
{ "mixramp_analyzer" },
{ "list_playlists_in_root"},
};

static constexpr unsigned n_config_param_templates =
Expand Down