Commit cf554d30 authored by Max Kellermann's avatar Max Kellermann

LocateUri: implement UriPluginKind::STORAGE properly

This way, URI schemes supported by arbitrary storage plugins are allowed. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1270
parent ef24cfa5
...@@ -2,6 +2,7 @@ ver 0.23 (not yet released) ...@@ -2,6 +2,7 @@ ver 0.23 (not yet released)
* protocol * protocol
- new command "getvol" - new command "getvol"
- show the audio format in "playlistinfo" - show the audio format in "playlistinfo"
- support "listfiles" with arbitrary storage plugins
* database * database
- proxy: require MPD 0.20 or later - proxy: require MPD 0.20 or later
- proxy: require libmpdclient 2.11 or later - proxy: require libmpdclient 2.11 or later
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "client/Client.hxx" #include "client/Client.hxx"
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
#include "ls.hxx" #include "ls.hxx"
#include "storage/Registry.hxx"
#include "util/ASCII.hxx" #include "util/ASCII.hxx"
#include "util/UriExtract.hxx" #include "util/UriExtract.hxx"
...@@ -67,11 +68,15 @@ LocateAbsoluteUri(UriPluginKind kind, const char *uri ...@@ -67,11 +68,15 @@ LocateAbsoluteUri(UriPluginKind kind, const char *uri
{ {
switch (kind) { switch (kind) {
case UriPluginKind::INPUT: case UriPluginKind::INPUT:
case UriPluginKind::STORAGE: // TODO: separate check for storage plugins
if (!uri_supported_scheme(uri)) if (!uri_supported_scheme(uri))
throw std::invalid_argument("Unsupported URI scheme"); throw std::invalid_argument("Unsupported URI scheme");
break; break;
case UriPluginKind::STORAGE:
/* plugin support will be checked after the
Storage::MapToRelativeUTF8() call */
break;
case UriPluginKind::PLAYLIST: case UriPluginKind::PLAYLIST:
/* for now, no validation for playlist URIs; this is /* for now, no validation for playlist URIs; this is
more complicated because there are three ways to more complicated because there are three ways to
...@@ -88,6 +93,10 @@ LocateAbsoluteUri(UriPluginKind kind, const char *uri ...@@ -88,6 +93,10 @@ LocateAbsoluteUri(UriPluginKind kind, const char *uri
return LocatedUri(LocatedUri::Type::RELATIVE, return LocatedUri(LocatedUri::Type::RELATIVE,
suffix.data()); suffix.data());
} }
if (kind == UriPluginKind::STORAGE &&
GetStoragePluginByUri(uri) == nullptr)
throw std::invalid_argument("Unsupported URI scheme");
#endif #endif
return LocatedUri(LocatedUri::Type::ABSOLUTE, uri); return LocatedUri(LocatedUri::Type::ABSOLUTE, uri);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment