From 92ed4d6b5b02b6839dd2f43398fcd8e9f0421bcd Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Wed, 22 Jan 2014 19:21:16 +0000 Subject: [PATCH] Mopidy sets DB time to 0, so need to handle this :-( --- models/dirviewmodel.cpp | 11 ++++++----- models/musiclibrarymodel.cpp | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/models/dirviewmodel.cpp b/models/dirviewmodel.cpp index d77cdc0b5..d08f4a9d5 100644 --- a/models/dirviewmodel.cpp +++ b/models/dirviewmodel.cpp @@ -420,12 +420,13 @@ void DirViewModel::updateDirView(DirViewItemRoot *newroot, const QDateTime &dbUp updatedListing=true; } - // MPD proxy DB plugin does not provide a datetime for the DB. Therefore, just use current datetime - // so that we dont keep requesting DB listing each time Cantata starts... + // MPD proxy DB plugin (MPD < 0.18.5) does not provide a datetime for the DB. Also, Mopidy + // returns 0 for the database time (which equates to 1am Jan 1st 1970!). Therefore, in these + // cases we just use current datetime so that we dont keep requesting DB listing each time + // Cantata starts... // - // Users of this plugin will have to force Cantata to refresh :-( - // - if (!databaseTime.isValid() && !dbUpdate.isValid()) { + // Mopidy users, and users of the proxy DB plugin, will have to force Cantata to refresh :-( + if ((!databaseTime.isValid() && !dbUpdate.isValid()) || (databaseTime.date().year()<2000 && dbUpdate.date().year()<2000)) { databaseTime=QDateTime::currentDateTime(); } diff --git a/models/musiclibrarymodel.cpp b/models/musiclibrarymodel.cpp index 5b467476a..3fd90a131 100644 --- a/models/musiclibrarymodel.cpp +++ b/models/musiclibrarymodel.cpp @@ -420,7 +420,7 @@ QSet MusicLibraryModel::getAlbumArtists() } return a; } - +#include void MusicLibraryModel::updateMusicLibrary(MusicLibraryItemRoot *newroot, QDateTime dbUpdate, bool fromFile) { if (!mpdModel || (databaseTime.isValid() && databaseTime >= dbUpdate)) { @@ -457,12 +457,13 @@ void MusicLibraryModel::updateMusicLibrary(MusicLibraryItemRoot *newroot, QDateT updatedSongs=true; } - // MPD proxy DB plugin does not provide a datetime for the DB. Therefore, just use current datetime - // so that we dont keep requesting DB listing each time Cantata starts... + // MPD proxy DB plugin (MPD < 0.18.5) does not provide a datetime for the DB. Also, Mopidy + // returns 0 for the database time (which equates to 1am Jan 1st 1970!). Therefore, in these + // cases we just use current datetime so that we dont keep requesting DB listing each time + // Cantata starts... // - // Users of this plugin will have to force Cantata to refresh :-( - // - if (!databaseTime.isValid() && !dbUpdate.isValid()) { + // Mopidy users, and users of the proxy DB plugin, will have to force Cantata to refresh :-( + if ((!databaseTime.isValid() && !dbUpdate.isValid()) || (databaseTime.date().year()<2000 && dbUpdate.date().year()<2000)) { databaseTime=QDateTime::currentDateTime(); }