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
d76b6f87
Commit
d76b6f87
authored
Feb 04, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/update/Service: add SimpleDatabase reference
Don't use the global variables from the DatabaseSimple library.
parent
f25ef8d6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
41 deletions
+24
-41
Main.cxx
src/Main.cxx
+2
-1
DatabaseGlue.cxx
src/db/DatabaseGlue.cxx
+4
-14
DatabaseSimple.hxx
src/db/DatabaseSimple.hxx
+3
-18
SimpleDatabasePlugin.hxx
src/db/plugins/SimpleDatabasePlugin.hxx
+4
-0
Service.hxx
src/db/update/Service.hxx
+5
-1
UpdateGlue.cxx
src/db/update/UpdateGlue.cxx
+6
-7
No files found.
src/Main.cxx
View file @
d76b6f87
...
...
@@ -68,6 +68,7 @@
#include "db/update/Service.hxx"
#include "db/DatabaseGlue.hxx"
#include "db/DatabaseSimple.hxx"
#include "db/plugins/SimpleDatabasePlugin.hxx"
#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
...
...
@@ -460,7 +461,7 @@ int mpd_main(int argc, char *argv[])
const
bool
create_db
=
!
glue_db_init_and_load
();
instance
->
update
=
db_is_simple
()
?
new
UpdateService
(
*
main_loop
)
?
new
UpdateService
(
*
main_loop
,
db_get_simple
()
)
:
nullptr
;
#endif
...
...
src/db/DatabaseGlue.cxx
View file @
d76b6f87
...
...
@@ -95,23 +95,13 @@ db_is_simple(void)
return
is_simple
;
}
Directory
*
db_get_
root
(
void
)
SimpleDatabase
&
db_get_
simple
(
)
{
assert
(
is_simple
);
assert
(
db
!=
nullptr
);
assert
(
db_is_simple
());
return
((
SimpleDatabase
*
)
db
)
->
GetRoot
();
}
bool
db_save
(
Error
&
error
)
{
assert
(
db
!=
nullptr
);
assert
(
db_is_open
);
assert
(
db_is_simple
());
return
((
SimpleDatabase
*
)
db
)
->
Save
(
error
)
;
return
*
(
SimpleDatabase
*
)
db
;
}
bool
...
...
src/db/DatabaseSimple.hxx
View file @
d76b6f87
...
...
@@ -22,12 +22,9 @@
#include "Compiler.h"
#include <sys/time.h>
struct
config_param
;
struct
Directory
;
struct
db_selection
;
struct
db_visitor
;
class
SimpleDatabase
;
class
Error
;
/**
...
...
@@ -38,21 +35,9 @@ class Error;
bool
db_is_simple
(
void
);
/**
* Returns the root directory object. Returns NULL if there is no
* configured music directory.
*
* May only be used if db_is_simple() returns true.
*/
gcc_pure
Directory
*
db_get_root
(
void
);
/**
* May only be used if db_is_simple() returns true.
*/
bool
db_save
(
Error
&
error
);
SimpleDatabase
&
db_get_simple
();
/**
* Returns true if there is a valid database file on the disk.
...
...
src/db/plugins/SimpleDatabasePlugin.hxx
View file @
d76b6f87
...
...
@@ -59,6 +59,10 @@ public:
bool
Save
(
Error
&
error
);
bool
FileExists
()
const
{
return
mtime
>
0
;
}
static
Database
*
Create
(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
const
config_param
&
param
,
Error
&
error
);
...
...
src/db/update/Service.hxx
View file @
d76b6f87
...
...
@@ -26,6 +26,8 @@
#include "event/DeferredMonitor.hxx"
#include "thread/Thread.hxx"
class
SimpleDatabase
;
/**
* This class manages the update queue and runs the update thread.
*/
...
...
@@ -36,6 +38,8 @@ class UpdateService final : DeferredMonitor {
UPDATE_PROGRESS_DONE
=
2
};
SimpleDatabase
&
db
;
Progress
progress
;
bool
modified
;
...
...
@@ -53,7 +57,7 @@ class UpdateService final : DeferredMonitor {
UpdateWalk
walk
;
public
:
UpdateService
(
EventLoop
&
_loop
);
UpdateService
(
EventLoop
&
_loop
,
SimpleDatabase
&
_db
);
/**
* Returns a non-zero job id when we are currently updating
...
...
src/db/update/UpdateGlue.cxx
View file @
d76b6f87
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "Service.hxx"
#include "UpdateDomain.hxx"
#include "db/
DatabaseSimple
.hxx"
#include "db/
plugins/SimpleDatabasePlugin
.hxx"
#include "Idle.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
...
...
@@ -44,12 +44,12 @@ UpdateService::Task()
SetThreadIdlePriority
();
modified
=
walk
.
Walk
(
*
db
_get_r
oot
(),
next
.
path_utf8
.
c_str
(),
modified
=
walk
.
Walk
(
*
db
.
GetR
oot
(),
next
.
path_utf8
.
c_str
(),
next
.
discard
);
if
(
modified
||
!
db
_e
xists
())
{
if
(
modified
||
!
db
.
FileE
xists
())
{
Error
error
;
if
(
!
db
_s
ave
(
error
))
if
(
!
db
.
S
ave
(
error
))
LogError
(
error
,
"Failed to save database"
);
}
...
...
@@ -146,8 +146,7 @@ UpdateService::RunDeferred()
}
}
UpdateService
::
UpdateService
(
EventLoop
&
_loop
)
:
DeferredMonitor
(
_loop
),
walk
(
_loop
)
UpdateService
::
UpdateService
(
EventLoop
&
_loop
,
SimpleDatabase
&
_db
)
:
DeferredMonitor
(
_loop
),
db
(
_db
),
walk
(
_loop
)
{
assert
(
db_is_simple
());
}
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