Fix `lsinfo` and `add` for mounted databases.

If `SimpleDatabase::Visit` is called on a database that contains a mounted directry the URIs of the elements passed to the callbacks are not prefixed by the mountpoint path. This leads to lsinfo and add not working because they use the wrong URI. This pull request is using the `WalkMount` helper function to create prefixed versions of `VisitDirectory`, `VisitSong` and `VisitPlaylist` to add the correct prefix to the parameters of the callback functions.
This commit is contained in:
FlashSystems 2017-12-02 19:39:17 +01:00 committed by Max Kellermann
parent 967af60327
commit c488d3123f
5 changed files with 18 additions and 4 deletions

1
NEWS
View File

@ -6,6 +6,7 @@ ver 0.20.13 (not yet released)
* database
- simple: don't purge mount points on update/rescan
- simple: fix "mount" bug caused by bad compiler optimization
- simple: fix "lsinfo" into mount points
- upnp: work around libupnp 1.6.24 API breakage
* queue: fix spuriously misplaced prioritized songs
* include Windows cross-build script in source tarball

View File

@ -230,7 +230,7 @@ Directory::Walk(bool recursive, const SongFilter *filter,
call will lock it again */
const ScopeDatabaseUnlock unlock;
WalkMount(GetPath(), *mounted_database,
recursive, filter,
"", recursive, filter,
visit_directory, visit_song,
visit_playlist);
return;

View File

@ -72,7 +72,7 @@ PrefixVisitPlaylist(const char *base, const VisitPlaylist &visit_playlist,
void
WalkMount(const char *base, const Database &db,
bool recursive, const SongFilter *filter,
const char* uri, bool recursive, const SongFilter *filter,
const VisitDirectory &visit_directory, const VisitSong &visit_song,
const VisitPlaylist &visit_playlist)
{
@ -93,5 +93,5 @@ WalkMount(const char *base, const Database &db,
vp = std::bind(PrefixVisitPlaylist,
base, std::ref(visit_playlist), _1, _2);
db.Visit(DatabaseSelection("", recursive, filter), vd, vs, vp);
db.Visit(DatabaseSelection(uri, recursive, filter), vd, vs, vp);
}

View File

@ -27,7 +27,7 @@ class SongFilter;
void
WalkMount(const char *base, const Database &db,
bool recursive, const SongFilter *filter,
const char* uri, bool recursive, const SongFilter *filter,
const VisitDirectory &visit_directory, const VisitSong &visit_song,
const VisitPlaylist &visit_playlist);

View File

@ -20,6 +20,7 @@
#include "config.h"
#include "SimpleDatabasePlugin.hxx"
#include "PrefixedLightSong.hxx"
#include "Mount.hxx"
#include "db/DatabasePlugin.hxx"
#include "db/Selection.hxx"
#include "db/Helpers.hxx"
@ -270,6 +271,18 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
ScopeDatabaseLock protect;
auto r = root->LookupDirectory(selection.uri.c_str());
if (r.directory->IsMount()) {
/* pass the request and the remaining uri to the mounted database */
protect.unlock();
WalkMount(r.directory->GetPath(), *(r.directory->mounted_database),
(r.uri == nullptr)?"":r.uri, selection.recursive, selection.filter,
visit_directory, visit_song, visit_playlist);
return;
}
if (r.uri == nullptr) {
/* it's a directory */