Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
651f57bc
Commit
651f57bc
authored
Nov 11, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/playlist: save only if at least one song was added
parent
b4e72aba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
8 deletions
+18
-8
PlaylistCommands.cxx
src/command/PlaylistCommands.cxx
+6
-4
DatabasePlaylist.cxx
src/db/DatabasePlaylist.cxx
+8
-3
DatabasePlaylist.hxx
src/db/DatabasePlaylist.hxx
+4
-1
No files found.
src/command/PlaylistCommands.cxx
View file @
651f57bc
...
...
@@ -233,10 +233,12 @@ handle_playlistadd_position(Client &client, const char *playlist_name,
#ifdef ENABLE_DATABASE
const
DatabaseSelection
selection
(
uri
,
true
,
nullptr
);
SearchInsertIntoPlaylist
(
client
.
GetDatabaseOrThrow
(),
client
.
GetStorage
(),
selection
,
editor
,
position
);
if
(
SearchInsertIntoPlaylist
(
client
.
GetDatabaseOrThrow
(),
client
.
GetStorage
(),
selection
,
editor
,
position
)
==
0
)
/* no song was found, don't need to save */
return
CommandResult
::
OK
;
#else
(
void
)
client
;
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"No database"
);
...
...
src/db/DatabasePlaylist.cxx
View file @
651f57bc
...
...
@@ -42,7 +42,7 @@ search_add_to_playlist(const Database &db, const Storage *storage,
db
.
Visit
(
selection
,
f
);
}
voi
d
unsigne
d
SearchInsertIntoPlaylist
(
const
Database
&
db
,
const
Storage
*
storage
,
const
DatabaseSelection
&
selection
,
PlaylistFileEditor
&
playlist
,
...
...
@@ -50,9 +50,14 @@ SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
{
assert
(
position
<=
playlist
.
size
());
db
.
Visit
(
selection
,
[
&
playlist
,
&
position
,
storage
](
const
auto
&
song
){
playlist
.
Insert
(
position
,
unsigned
n
=
0
;
db
.
Visit
(
selection
,
[
&
playlist
,
&
position
,
&
n
,
storage
](
const
auto
&
song
){
playlist
.
Insert
(
position
+
n
,
DatabaseDetachSong
(
storage
,
song
));
++
position
;
++
n
;
});
return
n
;
}
src/db/DatabasePlaylist.hxx
View file @
651f57bc
...
...
@@ -33,7 +33,10 @@ search_add_to_playlist(const Database &db, const Storage *storage,
const
char
*
playlist_path_utf8
,
const
DatabaseSelection
&
selection
);
void
/**
* @return the number of songs added
*/
unsigned
SearchInsertIntoPlaylist
(
const
Database
&
db
,
const
Storage
*
storage
,
const
DatabaseSelection
&
selection
,
PlaylistFileEditor
&
playlist
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment