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
d2594c63
Commit
d2594c63
authored
Jul 17, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/Configured: use struct ConfigData
parent
667daab0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
Main.cxx
src/Main.cxx
+4
-4
Configured.cxx
src/storage/Configured.cxx
+10
-10
Configured.hxx
src/storage/Configured.hxx
+3
-2
No files found.
src/Main.cxx
View file @
d2594c63
...
...
@@ -166,9 +166,9 @@ glue_mapper_init(const ConfigData &config)
#ifdef ENABLE_DATABASE
static
void
InitStorage
(
EventLoop
&
event_loop
)
InitStorage
(
const
ConfigData
&
config
,
EventLoop
&
event_loop
)
{
auto
storage
=
CreateConfiguredStorage
(
event_loop
);
auto
storage
=
CreateConfiguredStorage
(
config
,
event_loop
);
if
(
storage
==
nullptr
)
return
;
...
...
@@ -193,7 +193,7 @@ glue_db_init_and_load(const ConfigData &config)
return
true
;
if
(
instance
->
database
->
GetPlugin
().
flags
&
DatabasePlugin
::
FLAG_REQUIRE_STORAGE
)
{
InitStorage
(
instance
->
io_thread
.
GetEventLoop
());
InitStorage
(
config
,
instance
->
io_thread
.
GetEventLoop
());
if
(
instance
->
storage
==
nullptr
)
{
delete
instance
->
database
;
...
...
@@ -204,7 +204,7 @@ glue_db_init_and_load(const ConfigData &config)
return
true
;
}
}
else
{
if
(
IsStorageConfigured
())
if
(
IsStorageConfigured
(
config
))
LogDefault
(
config_domain
,
"Ignoring the storage configuration "
"because the database does not need it"
);
...
...
src/storage/Configured.cxx
View file @
d2594c63
...
...
@@ -22,7 +22,7 @@
#include "Registry.hxx"
#include "StorageInterface.hxx"
#include "plugins/LocalStorage.hxx"
#include "config/
Global
.hxx"
#include "config/
Data
.hxx"
#include "config/Domain.hxx"
#include "fs/StandardDirectory.hxx"
#include "fs/CheckFile.hxx"
...
...
@@ -42,9 +42,9 @@ CreateConfiguredStorageUri(EventLoop &event_loop, const char *uri)
}
static
AllocatedPath
GetConfiguredMusicDirectory
()
GetConfiguredMusicDirectory
(
const
ConfigData
&
config
)
{
AllocatedPath
path
=
config
_get_p
ath
(
ConfigOption
::
MUSIC_DIR
);
AllocatedPath
path
=
config
.
GetP
ath
(
ConfigOption
::
MUSIC_DIR
);
if
(
path
.
IsNull
())
path
=
GetUserMusicDir
();
...
...
@@ -52,9 +52,9 @@ GetConfiguredMusicDirectory()
}
static
std
::
unique_ptr
<
Storage
>
CreateConfiguredStorageLocal
()
CreateConfiguredStorageLocal
(
const
ConfigData
&
config
)
{
AllocatedPath
path
=
GetConfiguredMusicDirectory
();
AllocatedPath
path
=
GetConfiguredMusicDirectory
(
config
);
if
(
path
.
IsNull
())
return
nullptr
;
...
...
@@ -64,17 +64,17 @@ CreateConfiguredStorageLocal()
}
std
::
unique_ptr
<
Storage
>
CreateConfiguredStorage
(
EventLoop
&
event_loop
)
CreateConfiguredStorage
(
const
ConfigData
&
config
,
EventLoop
&
event_loop
)
{
auto
uri
=
config
_get_s
tring
(
ConfigOption
::
MUSIC_DIR
);
auto
uri
=
config
.
GetS
tring
(
ConfigOption
::
MUSIC_DIR
);
if
(
uri
!=
nullptr
&&
uri_has_scheme
(
uri
))
return
CreateConfiguredStorageUri
(
event_loop
,
uri
);
return
CreateConfiguredStorageLocal
();
return
CreateConfiguredStorageLocal
(
config
);
}
bool
IsStorageConfigured
()
noexcept
IsStorageConfigured
(
const
ConfigData
&
config
)
noexcept
{
return
config
_get_string
(
ConfigOption
::
MUSIC_DIR
)
!=
nullptr
;
return
config
.
GetParam
(
ConfigOption
::
MUSIC_DIR
)
!=
nullptr
;
}
src/storage/Configured.hxx
View file @
d2594c63
...
...
@@ -25,6 +25,7 @@
#include <memory>
struct
ConfigData
;
class
Storage
;
class
EventLoop
;
...
...
@@ -35,13 +36,13 @@ class EventLoop;
* Throws #std::runtime_error on error.
*/
std
::
unique_ptr
<
Storage
>
CreateConfiguredStorage
(
EventLoop
&
event_loop
);
CreateConfiguredStorage
(
const
ConfigData
&
config
,
EventLoop
&
event_loop
);
/**
* Returns true if there is configuration for a #Storage instance.
*/
gcc_const
bool
IsStorageConfigured
()
noexcept
;
IsStorageConfigured
(
const
ConfigData
&
config
)
noexcept
;
#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