db/update/Walk: add Directory reference parameter

Remove dependency on the DatabaseSimple library.
This commit is contained in:
Max Kellermann 2014-02-04 08:57:40 +01:00
parent 33a2c01ea2
commit f25ef8d682
3 changed files with 14 additions and 14 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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