aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-04 08:57:40 +0100
committerMax Kellermann <max@duempel.org>2014-02-04 09:05:32 +0100
commitf25ef8d6825c03aec4569c6ad4b9bfb3a9f5d78d (patch)
treef0ad647783c635c72bd7004b34dbae01ad2d3970 /src
parent33a2c01ea2e6c06922eb0ce6a8f08760206138b4 (diff)
downloadmpd-f25ef8d6825c03aec4569c6ad4b9bfb3a9f5d78d.tar.gz
mpd-f25ef8d6825c03aec4569c6ad4b9bfb3a9f5d78d.tar.xz
mpd-f25ef8d6825c03aec4569c6ad4b9bfb3a9f5d78d.zip
db/update/Walk: add Directory reference parameter
Remove dependency on the DatabaseSimple library.
Diffstat (limited to 'src')
-rw-r--r--src/db/update/UpdateGlue.cxx3
-rw-r--r--src/db/update/Walk.cxx18
-rw-r--r--src/db/update/Walk.hxx7
3 files changed, 14 insertions, 14 deletions
diff --git a/src/db/update/UpdateGlue.cxx b/src/db/update/UpdateGlue.cxx
index 285143ffe..742fbfe98 100644
--- a/src/db/update/UpdateGlue.cxx
+++ b/src/db/update/UpdateGlue.cxx
@@ -44,7 +44,8 @@ UpdateService::Task()
SetThreadIdlePriority();
- modified = walk.Walk(next.path_utf8.c_str(), next.discard);
+ modified = walk.Walk(*db_get_root(), next.path_utf8.c_str(),
+ next.discard);
if (modified || !db_exists()) {
Error error;
diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx
index ff59fe960..ed09c1676 100644
--- a/src/db/update/Walk.cxx
+++ b/src/db/update/Walk.cxx
@@ -23,7 +23,6 @@
#include "Editor.hxx"
#include "UpdateDomain.hxx"
#include "db/DatabaseLock.hxx"
-#include "db/DatabaseSimple.hxx"
#include "db/Directory.hxx"
#include "db/Song.hxx"
#include "db/PlaylistVector.hxx"
@@ -393,9 +392,9 @@ UpdateWalk::DirectoryMakeChildChecked(Directory &parent, const char *name_utf8)
}
inline Directory *
-UpdateWalk::DirectoryMakeUriParentChecked(const char *uri)
+UpdateWalk::DirectoryMakeUriParentChecked(Directory &root, const char *uri)
{
- Directory *directory = db_get_root();
+ Directory *directory = &root;
char *duplicated = xstrdup(uri);
char *name_utf8 = duplicated, *slash;
@@ -418,9 +417,9 @@ UpdateWalk::DirectoryMakeUriParentChecked(const char *uri)
}
inline void
-UpdateWalk::UpdateUri(const char *uri)
+UpdateWalk::UpdateUri(Directory &root, const char *uri)
{
- Directory *parent = DirectoryMakeUriParentChecked(uri);
+ Directory *parent = DirectoryMakeUriParentChecked(root, uri);
if (parent == nullptr)
return;
@@ -435,19 +434,18 @@ UpdateWalk::UpdateUri(const char *uri)
}
bool
-UpdateWalk::Walk(const char *path, bool discard)
+UpdateWalk::Walk(Directory &root, const char *path, bool discard)
{
walk_discard = discard;
modified = false;
if (path != nullptr && !isRootDirectory(path)) {
- UpdateUri(path);
+ UpdateUri(root, path);
} else {
- Directory *directory = db_get_root();
struct stat st;
- if (stat_directory(*directory, &st) == 0)
- UpdateDirectory(*directory, &st);
+ if (stat_directory(root, &st) == 0)
+ UpdateDirectory(root, &st);
}
return modified;
diff --git a/src/db/update/Walk.hxx b/src/db/update/Walk.hxx
index 12274ccdf..ecb04387d 100644
--- a/src/db/update/Walk.hxx
+++ b/src/db/update/Walk.hxx
@@ -54,7 +54,7 @@ public:
/**
* Returns true if the database was modified.
*/
- bool Walk(const char *path, bool discard);
+ bool Walk(Directory &root, const char *path, bool discard);
private:
gcc_pure
@@ -126,9 +126,10 @@ private:
Directory *DirectoryMakeChildChecked(Directory &parent,
const char *name_utf8);
- Directory *DirectoryMakeUriParentChecked(const char *uri);
+ Directory *DirectoryMakeUriParentChecked(Directory &root,
+ const char *uri);
- void UpdateUri(const char *uri);
+ void UpdateUri(Directory &root, const char *uri);
};
#endif