diff options
author | Max Kellermann <max@duempel.org> | 2014-01-29 20:16:43 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-30 18:47:05 +0100 |
commit | c6725884bc155da431889468c86c546f0f64f9a1 (patch) | |
tree | 61d89751ecc98db9600620ac1788f32dea9214e1 /src/db/update/Container.cxx | |
parent | a31738f6f1473f4f621bc16513ed0c6024749389 (diff) | |
download | mpd-c6725884bc155da431889468c86c546f0f64f9a1.tar.gz mpd-c6725884bc155da431889468c86c546f0f64f9a1.tar.xz mpd-c6725884bc155da431889468c86c546f0f64f9a1.zip |
db/update: convert to OO API
Move global variables into the new classes. That may allow multiple
update threads for multiple databases one day.
Diffstat (limited to '')
-rw-r--r-- | src/db/update/Container.cxx (renamed from src/db/update/UpdateContainer.cxx) | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/db/update/UpdateContainer.cxx b/src/db/update/Container.cxx index c03d88748..38aacea0a 100644 --- a/src/db/update/UpdateContainer.cxx +++ b/src/db/update/Container.cxx @@ -18,9 +18,7 @@ */ #include "config.h" /* must be first for large file support */ -#include "UpdateContainer.hxx" -#include "UpdateInternal.hxx" -#include "UpdateDatabase.hxx" +#include "Walk.hxx" #include "UpdateDomain.hxx" #include "db/DatabaseLock.hxx" #include "db/Directory.hxx" @@ -33,19 +31,13 @@ #include "tag/TagBuilder.hxx" #include "Log.hxx" +#include <sys/stat.h> + #include <glib.h> -/** - * Create the specified directory object if it does not exist already - * or if the #stat object indicates that it has been modified since - * the last update. Returns nullptr when it exists already and is - * unmodified. - * - * The caller must lock the database. - */ -static Directory * -make_directory_if_modified(Directory &parent, const char *name, - const struct stat *st) +Directory * +UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name, + const struct stat *st) { Directory *directory = parent.FindChild(name); @@ -56,7 +48,7 @@ make_directory_if_modified(Directory &parent, const char *name, return nullptr; } - delete_directory(directory); + editor.DeleteDirectory(directory); modified = true; } @@ -73,10 +65,9 @@ SupportsContainerSuffix(const DecoderPlugin &plugin, const char *suffix) } bool -update_container_file(Directory &directory, - const char *name, - const struct stat *st, - const char *suffix) +UpdateWalk::UpdateContainerFile(Directory &directory, + const char *name, const char *suffix, + const struct stat *st) { const DecoderPlugin *_plugin = decoder_plugins_find([suffix](const DecoderPlugin &plugin){ return SupportsContainerSuffix(plugin, suffix); @@ -86,7 +77,7 @@ update_container_file(Directory &directory, const DecoderPlugin &plugin = *_plugin; db_lock(); - Directory *contdir = make_directory_if_modified(directory, name, st); + Directory *contdir = MakeDirectoryIfModified(directory, name, st); if (contdir == nullptr) { /* not modified */ db_unlock(); @@ -128,7 +119,7 @@ update_container_file(Directory &directory, if (tnum == 1) { db_lock(); - delete_directory(contdir); + editor.DeleteDirectory(contdir); db_unlock(); return false; } else |