db/proxy: fall back to recursive walk on old libmpdclient/MPD
Error message was 'too few arguments for "find"' because the "base" constraint was not supported, and no other constraints remained.
This commit is contained in:
parent
4c8a5dfb05
commit
848ed14788
1
NEWS
1
NEWS
|
@ -1,6 +1,7 @@
|
||||||
ver 0.18.12 (not yet released)
|
ver 0.18.12 (not yet released)
|
||||||
* database
|
* database
|
||||||
- proxy: fix build failure with libmpdclient 2.2
|
- proxy: fix build failure with libmpdclient 2.2
|
||||||
|
- proxy: fix add/search and other commands with libmpdclient < 2.9
|
||||||
|
|
||||||
ver 0.18.11 (2014/05/12)
|
ver 0.18.11 (2014/05/12)
|
||||||
* decoder
|
* decoder
|
||||||
|
|
|
@ -30,6 +30,18 @@ DatabaseSelection::DatabaseSelection(const char *_uri, bool _recursive,
|
||||||
uri = filter->GetBase();
|
uri = filter->GetBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
DatabaseSelection::IsEmpty() const
|
||||||
|
{
|
||||||
|
return uri.empty() && (filter == nullptr || filter->IsEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
DatabaseSelection::HasOtherThanBase() const
|
||||||
|
{
|
||||||
|
return filter != nullptr && filter->HasOtherThanBase();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DatabaseSelection::Match(const Song &song) const
|
DatabaseSelection::Match(const Song &song) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,15 @@ struct DatabaseSelection {
|
||||||
DatabaseSelection(const char *_uri, bool _recursive,
|
DatabaseSelection(const char *_uri, bool _recursive,
|
||||||
const SongFilter *_filter=nullptr);
|
const SongFilter *_filter=nullptr);
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
bool IsEmpty() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this selection contain constraints other than "base"?
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
bool HasOtherThanBase() const;
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool Match(const Song &song) const;
|
bool Match(const Song &song) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -203,6 +203,16 @@ SongFilter::Match(const Song &song) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SongFilter::HasOtherThanBase() const
|
||||||
|
{
|
||||||
|
for (const auto &i : items)
|
||||||
|
if (i.GetTag() != LOCATE_TAG_BASE_TYPE)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
SongFilter::GetBase() const
|
SongFilter::GetBase() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,6 +109,11 @@ public:
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
bool IsEmpty() const {
|
||||||
|
return items.empty();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is there at least one item with "fold case" enabled?
|
* Is there at least one item with "fold case" enabled?
|
||||||
*/
|
*/
|
||||||
|
@ -121,6 +126,12 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this filter contain constraints other than "base"?
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
bool HasOtherThanBase() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the "base" specification (if there is one) or an
|
* Returns the "base" specification (if there is one) or an
|
||||||
* empty string.
|
* empty string.
|
||||||
|
|
|
@ -566,6 +566,23 @@ SearchSongs(struct mpd_connection *connection,
|
||||||
return result && CheckError(connection, error);
|
return result && CheckError(connection, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether we can use the "base" constraint. Requires
|
||||||
|
* libmpdclient 2.9 and MPD 0.18.
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
static bool
|
||||||
|
ServerSupportsSearchBase(const struct mpd_connection *connection)
|
||||||
|
{
|
||||||
|
#if LIBMPDCLIENT_CHECK_VERSION(2,9,0)
|
||||||
|
return mpd_connection_cmp_server_version(connection, 0, 18, 0) >= 0;
|
||||||
|
#else
|
||||||
|
(void)connection;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ProxyDatabase::Visit(const DatabaseSelection &selection,
|
ProxyDatabase::Visit(const DatabaseSelection &selection,
|
||||||
VisitDirectory visit_directory,
|
VisitDirectory visit_directory,
|
||||||
|
@ -577,7 +594,10 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
|
||||||
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
|
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!visit_directory && !visit_playlist && selection.recursive)
|
if (!visit_directory && !visit_playlist && selection.recursive &&
|
||||||
|
(ServerSupportsSearchBase(connection)
|
||||||
|
? !selection.IsEmpty()
|
||||||
|
: selection.HasOtherThanBase()))
|
||||||
/* this optimized code path can only be used under
|
/* this optimized code path can only be used under
|
||||||
certain conditions */
|
certain conditions */
|
||||||
return ::SearchSongs(connection, selection, visit_song, error);
|
return ::SearchSongs(connection, selection, visit_song, error);
|
||||||
|
|
Loading…
Reference in New Issue