db/update/Walk: add Directory reference parameter
Remove dependency on the DatabaseSimple library.
This commit is contained in:
parent
33a2c01ea2
commit
f25ef8d682
|
@ -44,7 +44,8 @@ UpdateService::Task()
|
||||||
|
|
||||||
SetThreadIdlePriority();
|
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()) {
|
if (modified || !db_exists()) {
|
||||||
Error error;
|
Error error;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "Editor.hxx"
|
#include "Editor.hxx"
|
||||||
#include "UpdateDomain.hxx"
|
#include "UpdateDomain.hxx"
|
||||||
#include "db/DatabaseLock.hxx"
|
#include "db/DatabaseLock.hxx"
|
||||||
#include "db/DatabaseSimple.hxx"
|
|
||||||
#include "db/Directory.hxx"
|
#include "db/Directory.hxx"
|
||||||
#include "db/Song.hxx"
|
#include "db/Song.hxx"
|
||||||
#include "db/PlaylistVector.hxx"
|
#include "db/PlaylistVector.hxx"
|
||||||
|
@ -393,9 +392,9 @@ UpdateWalk::DirectoryMakeChildChecked(Directory &parent, const char *name_utf8)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Directory *
|
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 *duplicated = xstrdup(uri);
|
||||||
char *name_utf8 = duplicated, *slash;
|
char *name_utf8 = duplicated, *slash;
|
||||||
|
|
||||||
|
@ -418,9 +417,9 @@ UpdateWalk::DirectoryMakeUriParentChecked(const char *uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
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)
|
if (parent == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -435,19 +434,18 @@ UpdateWalk::UpdateUri(const char *uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
UpdateWalk::Walk(const char *path, bool discard)
|
UpdateWalk::Walk(Directory &root, const char *path, bool discard)
|
||||||
{
|
{
|
||||||
walk_discard = discard;
|
walk_discard = discard;
|
||||||
modified = false;
|
modified = false;
|
||||||
|
|
||||||
if (path != nullptr && !isRootDirectory(path)) {
|
if (path != nullptr && !isRootDirectory(path)) {
|
||||||
UpdateUri(path);
|
UpdateUri(root, path);
|
||||||
} else {
|
} else {
|
||||||
Directory *directory = db_get_root();
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat_directory(*directory, &st) == 0)
|
if (stat_directory(root, &st) == 0)
|
||||||
UpdateDirectory(*directory, &st);
|
UpdateDirectory(root, &st);
|
||||||
}
|
}
|
||||||
|
|
||||||
return modified;
|
return modified;
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns true if the database was modified.
|
* Returns true if the database was modified.
|
||||||
*/
|
*/
|
||||||
bool Walk(const char *path, bool discard);
|
bool Walk(Directory &root, const char *path, bool discard);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gcc_pure
|
gcc_pure
|
||||||
|
@ -126,9 +126,10 @@ private:
|
||||||
Directory *DirectoryMakeChildChecked(Directory &parent,
|
Directory *DirectoryMakeChildChecked(Directory &parent,
|
||||||
const char *name_utf8);
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue