summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-05 17:50:04 +0100
committerMax Kellermann <max@duempel.org>2014-02-05 17:58:13 +0100
commit4c995eb49873eac081486a94c6ed8db566248563 (patch)
tree814bca7ff2a044b94d9e929aef028f34b471e3a0 /src
parent144cfe70bfb23ac5fdf328ed8b1492374d4b21f5 (diff)
db/UpdateWalk: move LocalStorage to Instance
Keep only a reference.
Diffstat (limited to 'src')
-rw-r--r--src/Instance.hxx4
-rw-r--r--src/Main.cxx4
-rw-r--r--src/db/update/Archive.cxx1
-rw-r--r--src/db/update/Container.cxx1
-rw-r--r--src/db/update/Service.hxx1
-rw-r--r--src/db/update/UpdateGlue.cxx3
-rw-r--r--src/db/update/Walk.cxx7
-rw-r--r--src/db/update/Walk.hxx7
8 files changed, 21 insertions, 7 deletions
diff --git a/src/Instance.hxx b/src/Instance.hxx
index 52b137ab6..ca129ce80 100644
--- a/src/Instance.hxx
+++ b/src/Instance.hxx
@@ -31,6 +31,7 @@ class NeighborGlue;
#ifdef ENABLE_DATABASE
#include "db/DatabaseListener.hxx"
class Database;
+class LocalStorage;
class UpdateService;
#endif
@@ -62,6 +63,8 @@ struct Instance final
#ifdef ENABLE_DATABASE
Database *database;
+ LocalStorage *storage;
+
UpdateService *update;
#endif
@@ -71,6 +74,7 @@ struct Instance final
Instance() {
#ifdef ENABLE_DATABASE
+ storage = nullptr;
update = nullptr;
#endif
}
diff --git a/src/Main.cxx b/src/Main.cxx
index 0849353a3..108c0abcb 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -69,6 +69,7 @@
#include "db/DatabaseGlue.hxx"
#include "db/DatabaseSimple.hxx"
#include "db/plugins/SimpleDatabasePlugin.hxx"
+#include "storage/LocalStorage.hxx"
#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
@@ -209,7 +210,10 @@ glue_db_init_and_load(void)
return true;
SimpleDatabase &db = *(SimpleDatabase *)instance->database;
+ instance->storage = new LocalStorage(mapper_get_music_directory_utf8(),
+ mapper_get_music_directory_fs());
instance->update = new UpdateService(*instance->event_loop, db,
+ *instance->storage,
*instance);
/* run database update after daemonization? */
diff --git a/src/db/update/Archive.cxx b/src/db/update/Archive.cxx
index 9874eb1f2..1cd147c16 100644
--- a/src/db/update/Archive.cxx
+++ b/src/db/update/Archive.cxx
@@ -23,6 +23,7 @@
#include "db/DatabaseLock.hxx"
#include "db/Directory.hxx"
#include "db/Song.hxx"
+#include "storage/LocalStorage.hxx"
#include "fs/AllocatedPath.hxx"
#include "storage/FileInfo.hxx"
#include "archive/ArchiveList.hxx"
diff --git a/src/db/update/Container.cxx b/src/db/update/Container.cxx
index 956db7209..54cfdfab7 100644
--- a/src/db/update/Container.cxx
+++ b/src/db/update/Container.cxx
@@ -23,6 +23,7 @@
#include "db/DatabaseLock.hxx"
#include "db/Directory.hxx"
#include "db/Song.hxx"
+#include "storage/LocalStorage.hxx"
#include "decoder/DecoderPlugin.hxx"
#include "decoder/DecoderList.hxx"
#include "fs/AllocatedPath.hxx"
diff --git a/src/db/update/Service.hxx b/src/db/update/Service.hxx
index a41c311b6..cc5a61588 100644
--- a/src/db/update/Service.hxx
+++ b/src/db/update/Service.hxx
@@ -61,6 +61,7 @@ class UpdateService final : DeferredMonitor {
public:
UpdateService(EventLoop &_loop, SimpleDatabase &_db,
+ LocalStorage &_storage,
DatabaseListener &_listener);
/**
diff --git a/src/db/update/UpdateGlue.cxx b/src/db/update/UpdateGlue.cxx
index 41640e0ef..037d280b0 100644
--- a/src/db/update/UpdateGlue.cxx
+++ b/src/db/update/UpdateGlue.cxx
@@ -151,10 +151,11 @@ UpdateService::RunDeferred()
}
UpdateService::UpdateService(EventLoop &_loop, SimpleDatabase &_db,
+ LocalStorage &_storage,
DatabaseListener &_listener)
:DeferredMonitor(_loop), db(_db), listener(_listener),
progress(UPDATE_PROGRESS_IDLE),
update_task_id(0),
- walk(_loop, _listener)
+ walk(_loop, _listener, _storage)
{
}
diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx
index e6bfdcfd9..d8b998f9e 100644
--- a/src/db/update/Walk.cxx
+++ b/src/db/update/Walk.cxx
@@ -27,6 +27,7 @@
#include "db/Song.hxx"
#include "db/PlaylistVector.hxx"
#include "db/Uri.hxx"
+#include "storage/LocalStorage.hxx"
#include "playlist/PlaylistRegistry.hxx"
#include "Mapper.hxx"
#include "ExcludeList.hxx"
@@ -47,9 +48,9 @@
#include <stdlib.h>
#include <errno.h>
-UpdateWalk::UpdateWalk(EventLoop &_loop, DatabaseListener &_listener)
- :storage(mapper_get_music_directory_utf8(),
- mapper_get_music_directory_fs()),
+UpdateWalk::UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
+ LocalStorage &_storage)
+ :storage(_storage),
editor(_loop, _listener)
{
#ifndef WIN32
diff --git a/src/db/update/Walk.hxx b/src/db/update/Walk.hxx
index c465ea7e1..33387ab55 100644
--- a/src/db/update/Walk.hxx
+++ b/src/db/update/Walk.hxx
@@ -22,7 +22,6 @@
#include "check.h"
#include "Editor.hxx"
-#include "storage/LocalStorage.hxx"
#include <sys/stat.h>
@@ -30,6 +29,7 @@ struct stat;
struct FileInfo;
struct Directory;
struct archive_plugin;
+class LocalStorage;
class ExcludeList;
class UpdateWalk final {
@@ -48,12 +48,13 @@ class UpdateWalk final {
bool walk_discard;
bool modified;
- LocalStorage storage;
+ LocalStorage &storage;
DatabaseEditor editor;
public:
- UpdateWalk(EventLoop &_loop, DatabaseListener &_listener);
+ UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
+ LocalStorage &_storage);
/**
* Returns true if the database was modified.