ProxyDatabasePlugin: use an artificial "root" directory
Fixes assertion failures in the Directory library.
This commit is contained in:
@@ -49,6 +49,7 @@ class ProxyDatabase : public Database {
|
|||||||
unsigned port;
|
unsigned port;
|
||||||
|
|
||||||
struct mpd_connection *connection;
|
struct mpd_connection *connection;
|
||||||
|
struct directory *root;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Database *Create(const struct config_param *param,
|
static Database *Create(const struct config_param *param,
|
||||||
@@ -124,6 +125,8 @@ ProxyDatabase::Open(GError **error_r)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
root = directory_new_root();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +135,7 @@ ProxyDatabase::Close()
|
|||||||
{
|
{
|
||||||
assert(connection != nullptr);
|
assert(connection != nullptr);
|
||||||
|
|
||||||
|
directory_free(root);
|
||||||
mpd_connection_free(connection);
|
mpd_connection_free(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,10 +335,13 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
|
|||||||
// TODO: match
|
// TODO: match
|
||||||
// TODO: auto-reconnect
|
// TODO: auto-reconnect
|
||||||
|
|
||||||
struct directory *parent = directory_new(selection.uri, nullptr);
|
struct directory *parent = *selection.uri == 0
|
||||||
|
? root
|
||||||
|
: directory_new(selection.uri, root);
|
||||||
bool success = ::Visit(connection, *parent, selection.recursive,
|
bool success = ::Visit(connection, *parent, selection.recursive,
|
||||||
visit_directory, visit_song, visit_playlist,
|
visit_directory, visit_song, visit_playlist,
|
||||||
error_r);
|
error_r);
|
||||||
|
if (parent != root)
|
||||||
directory_free(parent);
|
directory_free(parent);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user