From c6725884bc155da431889468c86c546f0f64f9a1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 29 Jan 2014 20:16:43 +0100 Subject: db/update: convert to OO API Move global variables into the new classes. That may allow multiple update threads for multiple databases one day. --- src/db/update/UpdateSong.cxx | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/db/update/UpdateSong.cxx') diff --git a/src/db/update/UpdateSong.cxx b/src/db/update/UpdateSong.cxx index ac2d01cd2..afd609f9a 100644 --- a/src/db/update/UpdateSong.cxx +++ b/src/db/update/UpdateSong.cxx @@ -18,11 +18,8 @@ */ #include "config.h" /* must be first for large file support */ -#include "UpdateSong.hxx" -#include "UpdateInternal.hxx" +#include "Service.hxx" #include "UpdateIO.hxx" -#include "UpdateDatabase.hxx" -#include "UpdateContainer.hxx" #include "UpdateDomain.hxx" #include "db/DatabaseLock.hxx" #include "db/Directory.hxx" @@ -32,10 +29,10 @@ #include -static void -update_song_file2(Directory &directory, - const char *name, const struct stat *st, - const char *suffix) +inline void +UpdateWalk::UpdateSongFile2(Directory &directory, + const char *name, const char *suffix, + const struct stat *st) { db_lock(); Song *song = directory.FindSong(name); @@ -47,7 +44,7 @@ update_song_file2(Directory &directory, directory.GetPath(), name); if (song != nullptr) { db_lock(); - delete_song(directory, song); + editor.DeleteSong(directory, song); db_unlock(); } @@ -56,10 +53,10 @@ update_song_file2(Directory &directory, if (!(song != nullptr && st->st_mtime == song->mtime && !walk_discard) && - update_container_file(directory, name, st, suffix)) { + UpdateContainerFile(directory, name, suffix, st)) { if (song != nullptr) { db_lock(); - delete_song(directory, song); + editor.DeleteSong(directory, song); db_unlock(); } @@ -92,7 +89,7 @@ update_song_file2(Directory &directory, "deleting unrecognized file %s/%s", directory.GetPath(), name); db_lock(); - delete_song(directory, song); + editor.DeleteSong(directory, song); db_unlock(); } @@ -101,13 +98,13 @@ update_song_file2(Directory &directory, } bool -update_song_file(Directory &directory, - const char *name, const char *suffix, - const struct stat *st) +UpdateWalk::UpdateSongFile(Directory &directory, + const char *name, const char *suffix, + const struct stat *st) { if (!decoder_plugins_supports_suffix(suffix)) return false; - update_song_file2(directory, name, st, suffix); + UpdateSongFile2(directory, name, suffix, st); return true; } -- cgit v1.2.3