diff options
-rw-r--r-- | src/DatabaseGlue.cxx | 6 | ||||
-rw-r--r-- | src/DatabasePlugin.hxx | 9 | ||||
-rw-r--r-- | src/DatabaseSimple.hxx | 16 | ||||
-rw-r--r-- | src/Stats.cxx | 5 | ||||
-rw-r--r-- | src/db/ProxyDatabasePlugin.cxx | 5 | ||||
-rw-r--r-- | src/db/SimpleDatabasePlugin.hxx | 11 |
6 files changed, 26 insertions, 26 deletions
diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx index e84503713..013a3e329 100644 --- a/src/DatabaseGlue.cxx +++ b/src/DatabaseGlue.cxx @@ -148,12 +148,12 @@ DatabaseGlobalOpen(Error &error) return true; } -time_t -db_get_mtime(void) +bool +db_exists() { assert(db != nullptr); assert(db_is_open); assert(db_is_simple()); - return ((SimpleDatabase *)db)->GetLastModified(); + return ((SimpleDatabase *)db)->GetUpdateStamp() > 0; } diff --git a/src/DatabasePlugin.hxx b/src/DatabasePlugin.hxx index 629dff329..ccf899389 100644 --- a/src/DatabasePlugin.hxx +++ b/src/DatabasePlugin.hxx @@ -30,6 +30,8 @@ #include "tag/TagType.h" #include "Compiler.h" +#include <time.h> + struct config_param; struct DatabaseSelection; struct db_visitor; @@ -132,6 +134,13 @@ public: virtual bool GetStats(const DatabaseSelection &selection, DatabaseStats &stats, Error &error) const = 0; + + /** + * Returns the time stamp of the last database update. + * Returns 0 if that is not not known/available. + */ + gcc_pure + virtual time_t GetUpdateStamp() const = 0; }; struct DatabasePlugin { diff --git a/src/DatabaseSimple.hxx b/src/DatabaseSimple.hxx index 124d78a30..6d52ac0b3 100644 --- a/src/DatabaseSimple.hxx +++ b/src/DatabaseSimple.hxx @@ -63,24 +63,12 @@ bool db_save(Error &error); /** - * May only be used if db_is_simple() returns true. - */ -gcc_pure -time_t -db_get_mtime(void); - -/** * Returns true if there is a valid database file on the disk. * * May only be used if db_is_simple() returns true. */ gcc_pure -static inline bool -db_exists(void) -{ - /* mtime is set only if the database file was loaded or saved - successfully */ - return db_get_mtime() > 0; -} +bool +db_exists(); #endif diff --git a/src/Stats.cxx b/src/Stats.cxx index d2d18d6a9..f224bdf49 100644 --- a/src/Stats.cxx +++ b/src/Stats.cxx @@ -83,10 +83,11 @@ db_stats_print(Client &client) stats.song_count, stats.total_duration); - if (db_is_simple()) + const time_t update_stamp = GetDatabase()->GetUpdateStamp(); + if (update_stamp > 0) client_printf(client, "db_update: %lu\n", - (unsigned long)db_get_mtime()); + (unsigned long)update_stamp); } void diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index fc99242ee..d4861623f 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -71,6 +71,11 @@ public: DatabaseStats &stats, Error &error) const override; + virtual time_t GetUpdateStamp() const override { + // TODO: implement + return 0; + } + private: bool Configure(const config_param ¶m, Error &error); diff --git a/src/db/SimpleDatabasePlugin.hxx b/src/db/SimpleDatabasePlugin.hxx index 24e150a97..dfe981dd8 100644 --- a/src/db/SimpleDatabasePlugin.hxx +++ b/src/db/SimpleDatabasePlugin.hxx @@ -26,8 +26,6 @@ #include <cassert> -#include <time.h> - struct Directory; class SimpleDatabase : public Database { @@ -55,11 +53,6 @@ public: bool Save(Error &error); - gcc_pure - time_t GetLastModified() const { - return mtime; - } - static Database *Create(const config_param ¶m, Error &error); @@ -85,6 +78,10 @@ public: DatabaseStats &stats, Error &error) const override; + virtual time_t GetUpdateStamp() const override { + return mtime; + } + protected: bool Configure(const config_param ¶m, Error &error); |