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
fe48e559
Commit
fe48e559
authored
Jul 06, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/storage: automatically scan new mounts
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/841
parent
d7744d2b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
4 deletions
+18
-4
NEWS
NEWS
+2
-0
StorageCommands.cxx
src/command/StorageCommands.cxx
+9
-1
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+4
-2
SimpleDatabasePlugin.hxx
src/db/plugins/simple/SimpleDatabasePlugin.hxx
+3
-1
No files found.
NEWS
View file @
fe48e559
ver 0.21.25 (not yet released)
ver 0.21.25 (not yet released)
* protocol:
* protocol:
- fix crash when using "rangeid" while playing
- fix crash when using "rangeid" while playing
* database
- simple: automatically scan new mounts
* storage
* storage
- fix disappearing mounts after mounting twice
- fix disappearing mounts after mounting twice
- udisks: fix reading ".mpdignore"
- udisks: fix reading ".mpdignore"
...
...
src/command/StorageCommands.cxx
View file @
fe48e559
...
@@ -220,8 +220,10 @@ handle_mount(Client &client, Request args, Response &r)
...
@@ -220,8 +220,10 @@ handle_mount(Client &client, Request args, Response &r)
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
if
(
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
.
GetDatabase
()))
{
if
(
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
.
GetDatabase
()))
{
bool
need_update
;
try
{
try
{
db
->
Mount
(
local_uri
,
remote_uri
);
need_update
=
!
db
->
Mount
(
local_uri
,
remote_uri
);
}
catch
(...)
{
}
catch
(...)
{
composite
.
Unmount
(
local_uri
);
composite
.
Unmount
(
local_uri
);
throw
;
throw
;
...
@@ -230,6 +232,12 @@ handle_mount(Client &client, Request args, Response &r)
...
@@ -230,6 +232,12 @@ handle_mount(Client &client, Request args, Response &r)
// TODO: call Instance::OnDatabaseModified()?
// TODO: call Instance::OnDatabaseModified()?
// TODO: trigger database update?
// TODO: trigger database update?
instance
.
EmitIdle
(
IDLE_DATABASE
);
instance
.
EmitIdle
(
IDLE_DATABASE
);
if
(
need_update
)
{
UpdateService
*
update
=
client
.
GetInstance
().
update
;
if
(
update
!=
nullptr
)
update
->
Enqueue
(
local_uri
,
false
);
}
}
}
#endif
#endif
...
...
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
fe48e559
...
@@ -428,7 +428,7 @@ IsUnsafeChar(char ch)
...
@@ -428,7 +428,7 @@ IsUnsafeChar(char ch)
return
!
IsSafeChar
(
ch
);
return
!
IsSafeChar
(
ch
);
}
}
void
bool
SimpleDatabase
::
Mount
(
const
char
*
local_uri
,
const
char
*
storage_uri
)
SimpleDatabase
::
Mount
(
const
char
*
local_uri
,
const
char
*
storage_uri
)
{
{
if
(
cache_path
.
IsNull
())
if
(
cache_path
.
IsNull
())
...
@@ -447,9 +447,11 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri)
...
@@ -447,9 +447,11 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri)
compress
);
compress
);
db
->
Open
();
db
->
Open
();
// TODO: update the new database instance?
bool
exists
=
db
->
FileExists
();
Mount
(
local_uri
,
std
::
move
(
db
));
Mount
(
local_uri
,
std
::
move
(
db
));
return
exists
;
}
}
inline
DatabasePtr
inline
DatabasePtr
...
...
src/db/plugins/simple/SimpleDatabasePlugin.hxx
View file @
fe48e559
...
@@ -103,9 +103,11 @@ public:
...
@@ -103,9 +103,11 @@ public:
/**
/**
* Throws #std::runtime_error on error.
* Throws #std::runtime_error on error.
*
* @return false if the mounted database needs to be updated
*/
*/
gcc_nonnull_all
gcc_nonnull_all
void
Mount
(
const
char
*
local_uri
,
const
char
*
storage_uri
);
bool
Mount
(
const
char
*
local_uri
,
const
char
*
storage_uri
);
gcc_nonnull_all
gcc_nonnull_all
bool
Unmount
(
const
char
*
uri
)
noexcept
;
bool
Unmount
(
const
char
*
uri
)
noexcept
;
...
...
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