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
150443b0
Commit
150443b0
authored
Feb 17, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DatabasePlugin: add FLAG_REQUIRE_STORAGE
Ignore the storage configuration if FLAG_REQUIRE_STORAGE is not set in the DatabasePlugin.
parent
9e36af79
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
11 deletions
+43
-11
Main.cxx
src/Main.cxx
+17
-9
DatabasePlugin.hxx
src/db/DatabasePlugin.hxx
+10
-0
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+1
-1
SimpleDatabasePlugin.cxx
src/db/plugins/SimpleDatabasePlugin.cxx
+1
-1
Configured.cxx
src/storage/Configured.cxx
+6
-0
Configured.hxx
src/storage/Configured.hxx
+8
-0
No files found.
src/Main.cxx
View file @
150443b0
...
...
@@ -67,6 +67,7 @@
#ifdef ENABLE_DATABASE
#include "db/update/Service.hxx"
#include "db/Configured.hxx"
#include "db/DatabasePlugin.hxx"
#include "db/plugins/SimpleDatabasePlugin.hxx"
#include "storage/Configured.hxx"
#include "storage/CompositeStorage.hxx"
...
...
@@ -177,16 +178,23 @@ glue_db_init_and_load(void)
return
true
;
}
if
(
!
InitStorage
(
error
))
FatalError
(
error
);
if
(
instance
->
database
->
GetPlugin
().
flags
&
DatabasePlugin
::
FLAG_REQUIRE_STORAGE
)
{
if
(
!
InitStorage
(
error
))
FatalError
(
error
);
if
(
instance
->
storage
==
nullptr
)
{
delete
instance
->
database
;
instance
->
database
=
nullptr
;
LogDefault
(
config_domain
,
"Found database setting without "
"music_directory - disabling database"
);
return
true
;
if
(
instance
->
storage
==
nullptr
)
{
delete
instance
->
database
;
instance
->
database
=
nullptr
;
LogDefault
(
config_domain
,
"Found database setting without "
"music_directory - disabling database"
);
return
true
;
}
}
else
{
if
(
IsStorageConfigured
())
LogDefault
(
config_domain
,
"Ignoring the storage configuration "
"because the database does not need it"
);
}
if
(
!
instance
->
database
->
Open
(
error
))
...
...
src/db/DatabasePlugin.hxx
View file @
150443b0
...
...
@@ -33,6 +33,12 @@ class DatabaseListener;
class
Database
;
struct
DatabasePlugin
{
/**
* This plugin requires a #Storage instance. It contains only
* cached metadata from files in the #Storage.
*/
static
constexpr
unsigned
FLAG_REQUIRE_STORAGE
=
0x1
;
const
char
*
name
;
unsigned
flags
;
...
...
@@ -43,6 +49,10 @@ struct DatabasePlugin {
Database
*
(
*
create
)(
EventLoop
&
loop
,
DatabaseListener
&
listener
,
const
config_param
&
param
,
Error
&
error
);
constexpr
bool
RequireStorage
()
const
{
return
flags
&
FLAG_REQUIRE_STORAGE
;
}
};
#endif
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
150443b0
...
...
@@ -780,6 +780,6 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection,
const
DatabasePlugin
proxy_db_plugin
=
{
"proxy"
,
0
,
DatabasePlugin
::
FLAG_REQUIRE_STORAGE
,
ProxyDatabase
::
Create
,
};
src/db/plugins/SimpleDatabasePlugin.cxx
View file @
150443b0
...
...
@@ -337,6 +337,6 @@ SimpleDatabase::Save(Error &error)
const
DatabasePlugin
simple_db_plugin
=
{
"simple"
,
0
,
DatabasePlugin
::
FLAG_REQUIRE_STORAGE
,
SimpleDatabase
::
Create
,
};
src/storage/Configured.cxx
View file @
150443b0
...
...
@@ -76,3 +76,9 @@ CreateConfiguredStorage(Error &error)
return
CreateConfiguredStorageLocal
(
error
);
}
bool
IsStorageConfigured
()
{
return
config_get_string
(
CONF_MUSIC_DIR
,
nullptr
)
!=
nullptr
;
}
src/storage/Configured.hxx
View file @
150443b0
...
...
@@ -21,6 +21,7 @@
#define MPD_STORAGE_CONFIG_HXX
#include "check.h"
#include "Compiler.h"
class
Error
;
class
Storage
;
...
...
@@ -33,4 +34,11 @@ class Storage;
Storage
*
CreateConfiguredStorage
(
Error
&
error
);
/**
* Returns true if there is configuration for a #Storage instance.
*/
gcc_const
bool
IsStorageConfigured
();
#endif
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