diff options
author | Max Kellermann <max@duempel.org> | 2012-08-08 08:54:19 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-08-08 09:27:42 +0200 |
commit | b504d631171c27969115f12e761aebb20d923028 (patch) | |
tree | b3d14e4ea3f55f61ad56ca7eb7fe94a83bb085bd | |
parent | b4b1728b6f673c398205d078c4935166ab31eb0c (diff) | |
download | mpd-b504d631171c27969115f12e761aebb20d923028.tar.gz mpd-b504d631171c27969115f12e761aebb20d923028.tar.xz mpd-b504d631171c27969115f12e761aebb20d923028.zip |
ProxyDatabasePlugin: use an artificial "root" directory
Fixes assertion failures in the Directory library.
-rw-r--r-- | src/db/ProxyDatabasePlugin.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index 3b2fb36a2..b941b9576 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -49,6 +49,7 @@ class ProxyDatabase : public Database { unsigned port; struct mpd_connection *connection; + struct directory *root; public: static Database *Create(const struct config_param *param, @@ -124,6 +125,8 @@ ProxyDatabase::Open(GError **error_r) return false; } + root = directory_new_root(); + return true; } @@ -132,6 +135,7 @@ ProxyDatabase::Close() { assert(connection != nullptr); + directory_free(root); mpd_connection_free(connection); } @@ -331,11 +335,14 @@ ProxyDatabase::Visit(const DatabaseSelection &selection, // TODO: match // 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, visit_directory, visit_song, visit_playlist, error_r); - directory_free(parent); + if (parent != root) + directory_free(parent); return success; } |