actions: add missing flag restriction for physical deletion

This commit is contained in:
Andrzej Rybczak
2014-08-27 02:01:44 +02:00
parent 1fc2ce2d3c
commit 8d1b10fb3e
6 changed files with 25 additions and 1 deletions

View File

@@ -347,6 +347,8 @@
#
#generate_win32_compatible_filenames = "yes"
#
#allow_for_physical_item_deletion = "no"
#
##
## Note: If you set this variable, ncmpcpp will try to
## get info from last.fm in language you set and if it

View File

@@ -240,6 +240,9 @@ If enabled, lyrics will be saved in song's directory, otherwise in ~/.lyrics. No
.B generate_win32_compatible_filenames = yes/no
If set to yes, filenames generated by ncmpcpp (with tag editor, for lyrics, artists etc.) will not contain the following characters: /\?*:|"<> - otherwise only slash (/) will not be used.
.TP
.B allow_for_physical_item_deletion = yes/no
If set to yes, it will be possible to physically delete files and directories from the disk in the browser.
.TP
.B lastfm_preferred_language = ISO 639 alpha-2 language code
If set, ncmpcpp will try to get info from last.fm in language you set and if it fails, it will fall back to english. Otherwise it will use english the first time.
.TP

View File

@@ -643,9 +643,19 @@ void DeletePlaylistItems::run()
bool DeleteBrowserItems::canBeRun() const
{
auto check_if_deletion_allowed = []() {
if (Config.allow_for_physical_item_deletion)
return true;
else
{
Statusbar::msg("Flag 'allow_for_physical_item_deletion' needs to be enabled in configuration file");
return false;
}
};
return myScreen == myBrowser
&& !myBrowser->main().empty()
&& isMPDMusicDirSet();
&& isMPDMusicDirSet()
&& check_if_deletion_allowed();
}
void DeleteBrowserItems::run()

View File

@@ -543,6 +543,8 @@ void Browser::ChangeBrowseMode()
bool Browser::deleteItem(const MPD::Item &item, std::string &errmsg)
{
if (!Config.allow_for_physical_item_deletion)
FatalError("Browser::deleteItem invoked with allow_for_physical_item_deletion = false");
if (isParentDirectory((item)))
FatalError("Parent directory passed to Browser::deleteItem");

View File

@@ -217,6 +217,7 @@ void Configuration::SetDefaults()
store_lyrics_in_song_dir = false;
generate_win32_compatible_filenames = true;
ask_for_locked_screen_width_part = true;
allow_for_physical_item_deletion = false;
progressbar_boldness = true;
set_window_title = true;
mpd_port = 6600;
@@ -824,6 +825,11 @@ void Configuration::Read()
if (!v.empty())
ask_for_locked_screen_width_part = v == "yes";
}
else if (name == "allow_for_physical_item_deletion")
{
if (!v.empty())
allow_for_physical_item_deletion = v == "yes";
}
else if (name == "progressbar_boldness")
{
if (!v.empty())

View File

@@ -183,6 +183,7 @@ struct Configuration
bool store_lyrics_in_song_dir;
bool generate_win32_compatible_filenames;
bool ask_for_locked_screen_width_part;
bool allow_for_physical_item_deletion;
bool progressbar_boldness;
int mpd_port;