command/storage: automatically scan new mounts
Closes https://github.com/MusicPlayerDaemon/MPD/issues/841
This commit is contained in:
parent
d7744d2b8e
commit
fe48e5596f
2
NEWS
2
NEWS
@ -1,6 +1,8 @@
|
|||||||
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"
|
||||||
|
@ -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)
|
|||||||
// 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
|
||||||
|
|
||||||
|
@ -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)
|
|||||||
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
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user