summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--music.cpp9
-rw-r--r--music.h2
2 files changed, 7 insertions, 4 deletions
diff --git a/music.cpp b/music.cpp
index ee9f2ba..b9cb05d 100644
--- a/music.cpp
+++ b/music.cpp
@@ -145,13 +145,13 @@ void music::begin_update(const std::string path) {
MusicDirectory::p dir = get_directory(path);
std::cout << boost::format("updater(%s) called") % path << std::endl;
if(dir) {
- update(dir->path);
+ dir->update();
}
}
/** Recursively update \p dir and its subdirectories.
*/
-void music::update(const MusicDirectory& dir) {
+void MusicDirectory::update() {
// TODO: Fix engine-specific SQL syntax inside this function.
soci::session sql(config::vm["audist.database"].as<std::string>());
@@ -196,7 +196,10 @@ void music::update(const MusicDirectory& dir) {
}
sql.close();
- std::for_each(dir.directories.begin(), dir.directories.end(), update);
+ for(PathListings::iterator it = directories.begin(); it != directories.end(); it++) {
+ MusicDirectory dir(*it);
+ dir.update();
+ }
}
void MusicDirectory::render(HTTP::Connection::p req) {
diff --git a/music.h b/music.h
index f7d06bd..db69f5a 100644
--- a/music.h
+++ b/music.h
@@ -35,6 +35,7 @@ class MusicDirectory : public MusicListing {
MusicDirectory(const fs::path root);
virtual void render(HTTP::Connection::p req);
+ void update();
};
namespace music {
@@ -46,7 +47,6 @@ namespace music {
std::vector<MusicListing::p> find(const std::map<std::string, std::string> search);
std::vector<MusicListing::p> find(std::string search);
void begin_update(const std::string path);
- void update(const MusicDirectory& dir);
};
#endif