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
b0b086d4
Commit
b0b086d4
authored
Feb 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Main: move storage initialization to InitStorage()
parent
6798af52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
20 deletions
+27
-20
Main.cxx
src/Main.cxx
+27
-20
No files found.
src/Main.cxx
View file @
b0b086d4
...
...
@@ -135,38 +135,40 @@ glue_daemonize_init(const struct options *options, Error &error)
static
bool
glue_mapper_init
(
Error
&
error
)
{
auto
music_dir
=
config_get_path
(
CONF_MUSIC_DIR
,
error
);
if
(
music_dir
.
IsNull
()
&&
error
.
IsDefined
())
return
false
;
auto
playlist_dir
=
config_get_path
(
CONF_PLAYLIST_DIR
,
error
);
if
(
playlist_dir
.
IsNull
()
&&
error
.
IsDefined
())
return
false
;
if
(
music_dir
.
IsNull
())
music_dir
=
GetUserMusicDir
();
if
(
!
music_dir
.
IsNull
())
{
music_dir
.
ChopSeparators
();
CheckDirectoryReadable
(
music_dir
);
}
mapper_init
(
std
::
move
(
playlist_dir
));
return
true
;
}
#ifdef ENABLE_DATABASE
if
(
!
music_dir
.
IsNull
())
{
const
auto
music_dir_utf8
=
music_dir
.
ToUTF8
();
assert
(
!
music_dir_utf8
.
empty
());
instance
->
storage
=
CreateLocalStorage
(
music_dir_utf8
.
c_str
(),
music_dir
);
static
bool
InitStorage
(
Error
&
error
)
{
auto
path_fs
=
config_get_path
(
CONF_MUSIC_DIR
,
error
);
if
(
path_fs
.
IsNull
()
&&
error
.
IsDefined
())
return
false
;
if
(
path_fs
.
IsNull
())
{
path_fs
=
GetUserMusicDir
();
if
(
path_fs
.
IsNull
())
/* no music directory; that's ok */
return
true
;
}
#endif
mapper_init
(
std
::
move
(
playlist_dir
));
path_fs
.
ChopSeparators
();
CheckDirectoryReadable
(
path_fs
);
const
auto
utf8
=
path_fs
.
ToUTF8
();
assert
(
!
utf8
.
empty
());
instance
->
storage
=
CreateLocalStorage
(
utf8
.
c_str
(),
path_fs
);
return
true
;
}
#ifdef ENABLE_DATABASE
/**
* Returns the database. If this function returns false, this has not
* succeeded, and the caller should create the database after the
...
...
@@ -480,6 +482,11 @@ int mpd_main(int argc, char *argv[])
decoder_plugin_init_all
();
#ifdef ENABLE_DATABASE
if
(
!
InitStorage
(
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
const
bool
create_db
=
!
glue_db_init_and_load
();
#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