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
777e15bd
Commit
777e15bd
authored
Feb 08, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/DatabaseSong: make the Storage optional
Some database plugins don't use a Storage (e.g. UPnP), and with this plugin, DatabaseDetachSong() can crash.
parent
f689e289
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
15 deletions
+15
-15
SongLoader.cxx
src/SongLoader.cxx
+1
-1
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+1
-1
PlaylistCommands.cxx
src/command/PlaylistCommands.cxx
+1
-1
DatabasePlaylist.cxx
src/db/DatabasePlaylist.cxx
+3
-3
DatabasePlaylist.hxx
src/db/DatabasePlaylist.hxx
+1
-1
DatabaseQueue.cxx
src/db/DatabaseQueue.cxx
+1
-1
DatabaseSong.cxx
src/db/DatabaseSong.cxx
+4
-4
DatabaseSong.hxx
src/db/DatabaseSong.hxx
+2
-2
test_translate_song.cxx
test/test_translate_song.cxx
+1
-1
No files found.
src/SongLoader.cxx
View file @
777e15bd
...
...
@@ -41,7 +41,7 @@ SongLoader::LoadFromDatabase(const char *uri) const
{
#ifdef ENABLE_DATABASE
if
(
db
!=
nullptr
)
return
DatabaseDetachSong
(
*
db
,
*
storage
,
uri
);
return
DatabaseDetachSong
(
*
db
,
storage
,
uri
);
#else
(
void
)
uri
;
#endif
...
...
src/command/DatabaseCommands.cxx
View file @
777e15bd
...
...
@@ -134,7 +134,7 @@ handle_searchaddpl(Client &client, Request args, Response &r)
const
Database
&
db
=
client
.
GetDatabaseOrThrow
();
search_add_to_playlist
(
db
,
*
client
.
GetStorage
(),
search_add_to_playlist
(
db
,
client
.
GetStorage
(),
""
,
playlist
,
&
filter
);
return
CommandResult
::
OK
;
}
...
...
src/command/PlaylistCommands.cxx
View file @
777e15bd
...
...
@@ -166,7 +166,7 @@ handle_playlistadd(Client &client, Request args, gcc_unused Response &r)
#ifdef ENABLE_DATABASE
const
Database
&
db
=
client
.
GetDatabaseOrThrow
();
search_add_to_playlist
(
db
,
*
client
.
GetStorage
(),
search_add_to_playlist
(
db
,
client
.
GetStorage
(),
uri
,
playlist
,
nullptr
);
#else
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"directory or file not found"
);
...
...
src/db/DatabasePlaylist.cxx
View file @
777e15bd
...
...
@@ -28,7 +28,7 @@
#include <functional>
static
void
AddSong
(
const
Storage
&
storage
,
const
char
*
playlist_path_utf8
,
AddSong
(
const
Storage
*
storage
,
const
char
*
playlist_path_utf8
,
const
LightSong
&
song
)
{
spl_append_song
(
playlist_path_utf8
,
...
...
@@ -36,14 +36,14 @@ AddSong(const Storage &storage, const char *playlist_path_utf8,
}
void
search_add_to_playlist
(
const
Database
&
db
,
const
Storage
&
storage
,
search_add_to_playlist
(
const
Database
&
db
,
const
Storage
*
storage
,
const
char
*
uri
,
const
char
*
playlist_path_utf8
,
const
SongFilter
*
filter
)
{
const
DatabaseSelection
selection
(
uri
,
true
,
filter
);
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
AddSong
,
st
d
::
ref
(
storage
)
,
const
auto
f
=
std
::
bind
(
AddSong
,
st
orage
,
playlist_path_utf8
,
_1
);
db
.
Visit
(
selection
,
f
);
}
src/db/DatabasePlaylist.hxx
View file @
777e15bd
...
...
@@ -28,7 +28,7 @@ class SongFilter;
gcc_nonnull
(
3
,
4
)
void
search_add_to_playlist
(
const
Database
&
db
,
const
Storage
&
storage
,
search_add_to_playlist
(
const
Database
&
db
,
const
Storage
*
storage
,
const
char
*
uri
,
const
char
*
path_utf8
,
const
SongFilter
*
filter
);
...
...
src/db/DatabaseQueue.cxx
View file @
777e15bd
...
...
@@ -30,7 +30,7 @@
static
void
AddToQueue
(
Partition
&
partition
,
const
LightSong
&
song
)
{
const
Storage
&
storage
=
*
partition
.
instance
.
storage
;
const
auto
*
storage
=
partition
.
instance
.
storage
;
partition
.
playlist
.
AppendSong
(
partition
.
pc
,
DatabaseDetachSong
(
storage
,
song
));
...
...
src/db/DatabaseSong.cxx
View file @
777e15bd
...
...
@@ -28,21 +28,21 @@
#include <assert.h>
DetachedSong
DatabaseDetachSong
(
const
Storage
&
storage
,
const
LightSong
&
song
)
DatabaseDetachSong
(
const
Storage
*
storage
,
const
LightSong
&
song
)
{
DetachedSong
detached
(
song
);
assert
(
detached
.
IsInDatabase
());
if
(
!
detached
.
HasRealURI
())
{
if
(
!
detached
.
HasRealURI
()
&&
storage
!=
nullptr
)
{
const
auto
uri
=
song
.
GetURI
();
detached
.
SetRealURI
(
storage
.
MapUTF8
(
uri
.
c_str
()));
detached
.
SetRealURI
(
storage
->
MapUTF8
(
uri
.
c_str
()));
}
return
detached
;
}
DetachedSong
DatabaseDetachSong
(
const
Database
&
db
,
const
Storage
&
storage
,
const
char
*
uri
)
DatabaseDetachSong
(
const
Database
&
db
,
const
Storage
*
storage
,
const
char
*
uri
)
{
const
LightSong
*
tmp
=
db
.
GetSong
(
uri
);
assert
(
tmp
!=
nullptr
);
...
...
src/db/DatabaseSong.hxx
View file @
777e15bd
...
...
@@ -33,7 +33,7 @@ class DetachedSong;
*/
gcc_pure
DetachedSong
DatabaseDetachSong
(
const
Storage
&
storage
,
const
LightSong
&
song
);
DatabaseDetachSong
(
const
Storage
*
storage
,
const
LightSong
&
song
);
/**
* Look up a song in the database and convert it to a #DetachedSong
...
...
@@ -43,7 +43,7 @@ DatabaseDetachSong(const Storage &storage, const LightSong &song);
*/
gcc_pure
DetachedSong
DatabaseDetachSong
(
const
Database
&
db
,
const
Storage
&
storage
,
DatabaseDetachSong
(
const
Database
&
db
,
const
Storage
*
storage
,
const
char
*
uri
);
#endif
test/test_translate_song.cxx
View file @
777e15bd
...
...
@@ -109,7 +109,7 @@ static const char *uri2 = "foo/bar.ogg";
DetachedSong
DatabaseDetachSong
(
gcc_unused
const
Database
&
db
,
gcc_unused
const
Storage
&
_storage
,
gcc_unused
const
Storage
*
_storage
,
const
char
*
uri
)
{
if
(
strcmp
(
uri
,
uri2
)
==
0
)
...
...
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