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
21e19ef6
Commit
21e19ef6
authored
Feb 26, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple/Directory: eliminate method LookupSong()
Move to SimpleDatabase::GetSong() to give that method more control.
parent
69a42fc9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
30 deletions
+19
-30
Directory.cxx
src/db/plugins/simple/Directory.cxx
+0
-18
Directory.hxx
src/db/plugins/simple/Directory.hxx
+0
-11
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+19
-1
No files found.
src/db/plugins/simple/Directory.cxx
View file @
21e19ef6
...
@@ -202,24 +202,6 @@ Directory::FindSong(const char *name_utf8) const
...
@@ -202,24 +202,6 @@ Directory::FindSong(const char *name_utf8) const
return
nullptr
;
return
nullptr
;
}
}
Song
*
Directory
::
LookupSong
(
const
char
*
uri
)
{
assert
(
holding_db_lock
());
assert
(
uri
!=
nullptr
);
auto
r
=
LookupDirectory
(
uri
);
if
(
r
.
uri
==
nullptr
)
/* it's a directory */
return
nullptr
;
if
(
strchr
(
r
.
uri
,
'/'
)
!=
nullptr
)
/* refers to a URI "below" the actual song */
return
nullptr
;
return
r
.
directory
->
FindSong
(
r
.
uri
);
}
static
int
static
int
directory_cmp
(
gcc_unused
void
*
priv
,
directory_cmp
(
gcc_unused
void
*
priv
,
struct
list_head
*
_a
,
struct
list_head
*
_b
)
struct
list_head
*
_a
,
struct
list_head
*
_b
)
...
...
src/db/plugins/simple/Directory.hxx
View file @
21e19ef6
...
@@ -214,17 +214,6 @@ public:
...
@@ -214,17 +214,6 @@ public:
}
}
/**
/**
* Looks up a song by its relative URI.
*
* Caller must lock the #db_mutex.
*
* @param uri the relative URI
* @return the song, or nullptr if none was found
*/
gcc_pure
Song
*
LookupSong
(
const
char
*
uri
);
/**
* Add a song object to this directory. Its "parent" attribute must
* Add a song object to this directory. Its "parent" attribute must
* be set already.
* be set already.
*/
*/
...
...
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
21e19ef6
...
@@ -207,7 +207,25 @@ SimpleDatabase::GetSong(const char *uri, Error &error) const
...
@@ -207,7 +207,25 @@ SimpleDatabase::GetSong(const char *uri, Error &error) const
assert
(
borrowed_song_count
==
0
);
assert
(
borrowed_song_count
==
0
);
db_lock
();
db_lock
();
const
Song
*
song
=
root
->
LookupSong
(
uri
);
auto
r
=
root
->
LookupDirectory
(
uri
);
if
(
r
.
uri
==
nullptr
)
{
/* it's a directory */
db_unlock
();
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
"No such song: %s"
,
uri
);
return
nullptr
;
}
if
(
strchr
(
r
.
uri
,
'/'
)
!=
nullptr
)
{
/* refers to a URI "below" the actual song */
db_unlock
();
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
"No such song: %s"
,
uri
);
return
nullptr
;
}
const
Song
*
song
=
r
.
directory
->
FindSong
(
r
.
uri
);
db_unlock
();
db_unlock
();
if
(
song
==
nullptr
)
{
if
(
song
==
nullptr
)
{
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
error
.
Format
(
db_domain
,
DB_NOT_FOUND
,
...
...
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