Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

RFC: Scan notify - add "scanning" parameter to OnUpdate, OnRemove announcements #4298

Merged
merged 3 commits into from

3 participants

@jmarshallnz
Owner

For G+1.

@Montellese There's probably a smarter way to do this after some cleanup, but this is what I had in mind.

@MartijnKaijser MartijnKaijser added this to the Pending for inclusion milestone
@jmarshallnz
Owner

Updated the notifications.json - not sure if this is correct. @Montellese ?

@Montellese Montellese commented on the diff
xbmc/video/VideoDatabase.cpp
@@ -4504,15 +4505,13 @@ void CVideoDatabase::SetPlayCount(const CFileItem &item, int count, const CDateT
// We only need to announce changes to video items in the library
if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->m_iDbId > 0)
{
+ CVariant data;
+ if (g_application.IsVideoScanning())
@Montellese Owner

Is this correct? Is it even possible to set the playcount while the video info scanner is running?

@jmarshallnz Owner

The videoinfoscanner itself sets the playcount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Montellese
Owner

Changes to notification.json look correct.

@jmarshallnz
Owner

Thanks! jenkins build this please

@jmarshallnz jmarshallnz merged commit 9941b72 into xbmc:master
@jmarshallnz jmarshallnz deleted the jmarshallnz:scan_notify branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 3, 2014
  1. [videodb] move AnnounceUpdate|Remove to statics

    Jonathan Marshall authored
  2. [announces] add 'transaction' attribution to OnUpdate, OnRemove if sc…

    Jonathan Marshall authored
    …anning.
  3. drop unneeded tracking of database updating, using the 'transaction' …

    Jonathan Marshall authored
    …attribute of OnUpdate/OnRemove instead
This page is out of date. Refresh to see the latest.
View
12 xbmc/interfaces/json-rpc/schema/notifications.json
@@ -118,7 +118,8 @@
{ "name": "data", "type": "object", "required": true,
"properties": {
"id": { "$ref": "Library.Id", "required": true },
- "type": { "type": "string", "id": "Notifications.Library.Audio.Type", "enum": [ "song" ], "required": true }
+ "type": { "type": "string", "id": "Notifications.Library.Audio.Type", "enum": [ "song" ], "required": true },
+ "transaction": { "$ref": "Optional.Boolean", "description": "True if the update is being performed within a transaction." }
}
}
],
@@ -132,7 +133,8 @@
{ "name": "data", "type": "object", "required": true,
"properties": {
"id": { "$ref": "Library.Id", "required": true },
- "type": { "$ref": "Notifications.Library.Audio.Type", "required": true }
+ "type": { "$ref": "Notifications.Library.Audio.Type", "required": true },
+ "transaction": { "$ref": "Optional.Boolean", "description": "True if the removal is being performed within a transaction." }
}
}
],
@@ -183,7 +185,8 @@
"properties": {
"id": { "$ref": "Library.Id", "required": true },
"type": { "type": "string", "id": "Notifications.Library.Video.Type", "enum": [ "movie", "tvshow", "episode", "musicvideo" ], "required": true },
- "playcount": { "type": "integer", "minimum": 0, "default": -1 }
+ "playcount": { "type": "integer", "minimum": 0, "default": -1 },
+ "transaction": { "$ref": "Optional.Boolean", "description": "True if the update is being performed within a transaction." }
}
}
],
@@ -197,7 +200,8 @@
{ "name": "data", "type": "object", "required": true,
"properties": {
"id": { "$ref": "Library.Id", "required": true },
- "type": { "$ref": "Notifications.Library.Video.Type", "required": true }
+ "type": { "$ref": "Notifications.Library.Video.Type", "required": true },
+ "transaction": { "$ref": "Optional.Boolean", "description": "True if the removal is being performed within a transaction." }
}
}
],
View
2  xbmc/interfaces/json-rpc/schema/version.txt
@@ -1 +1 @@
-6.15.0
+6.15.1
View
17 xbmc/listproviders/DirectoryProvider.cpp
@@ -136,7 +136,6 @@ CDirectoryProvider::CDirectoryProvider(const TiXmlElement *element, int parentID
: IListProvider(parentID),
m_updateTime(0),
m_updateState(OK),
- m_isDbUpdating(false),
m_isAnnounced(false),
m_jobID(0)
{
@@ -194,24 +193,17 @@ void CDirectoryProvider::Announce(AnnouncementFlag flag, const char *sender, con
(std::find(m_itemTypes.begin(), m_itemTypes.end(), AUDIO) == m_itemTypes.end())))
return;
- // don't update while scanning / cleaning
- if (strcmp(message, "OnScanStarted") == 0 ||
- strcmp(message, "OnCleanStarted") == 0)
- {
- m_isDbUpdating = true;
+ // if we're in a database transaction, don't bother doing anything just yet
+ if (data.isMember("transaction") && data["transaction"].asBoolean())
return;
- }
// if there was a database update, we set the update state
// to PENDING to fire off a new job in the next update
if (strcmp(message, "OnScanFinished") == 0 ||
strcmp(message, "OnCleanFinished") == 0 ||
- ((strcmp(message, "OnUpdate") == 0 ||
- strcmp(message, "OnRemove") == 0) && !m_isDbUpdating))
- {
- m_isDbUpdating = false;
+ strcmp(message, "OnUpdate") == 0 ||
+ strcmp(message, "OnRemove") == 0)
m_updateState = PENDING;
- }
}
}
@@ -304,7 +296,6 @@ void CDirectoryProvider::RegisterListProvider(bool hasLibraryContent)
else if (!hasLibraryContent && m_isAnnounced)
{
m_isAnnounced = false;
- m_isDbUpdating = false;
CAnnouncementManager::RemoveAnnouncer(this);
}
}
View
1  xbmc/listproviders/DirectoryProvider.h
@@ -65,7 +65,6 @@ class CDirectoryProvider :
private:
unsigned int m_updateTime;
UpdateState m_updateState;
- bool m_isDbUpdating;
bool m_isAnnounced;
unsigned int m_jobID;
CGUIInfoLabel m_url;
View
4 xbmc/music/MusicDatabase.cpp
@@ -85,6 +85,8 @@ static void AnnounceRemove(const std::string& content, int id)
CVariant data;
data["type"] = content;
data["id"] = id;
+ if (g_application.IsMusicScanning())
+ data["transaction"] = true;
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnRemove", data);
}
@@ -93,6 +95,8 @@ static void AnnounceUpdate(const std::string& content, int id)
CVariant data;
data["type"] = content;
data["id"] = id;
+ if (g_application.IsMusicScanning())
+ data["transaction"] = true;
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnUpdate", data);
}
View
23 xbmc/video/VideoDatabase.cpp
@@ -59,6 +59,7 @@
#include "video/VideoDbUrl.h"
#include "playlists/SmartPlayList.h"
#include "utils/GroupUtils.h"
+#include "Application.h"
using namespace std;
using namespace dbiplus;
@@ -4504,15 +4505,13 @@ void CVideoDatabase::SetPlayCount(const CFileItem &item, int count, const CDateT
// We only need to announce changes to video items in the library
if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->m_iDbId > 0)
{
+ CVariant data;
+ if (g_application.IsVideoScanning())
@Montellese Owner

Is this correct? Is it even possible to set the playcount while the video info scanner is running?

@jmarshallnz Owner

The videoinfoscanner itself sets the playcount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ data["transaction"] = true;
// Only provide the "playcount" value if it has actually changed
if (item.GetVideoInfoTag()->m_playCount != count)
- {
- CVariant data;
data["playcount"] = count;
- ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", CFileItemPtr(new CFileItem(item)), data);
- }
- else
- ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", CFileItemPtr(new CFileItem(item)));
+ ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", CFileItemPtr(new CFileItem(item)), data);
}
}
catch (...)
@@ -8087,16 +8086,16 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
CLog::Log(LOGNOTICE, "%s: Cleaning videodatabase done. Operation took %s", __FUNCTION__, StringUtils::SecondsToTimeString(time / 1000).c_str());
for (std::vector<int>::const_iterator it = movieIDs.begin(); it != movieIDs.end(); ++it)
- AnnounceRemove(MediaTypeMovie, *it);
+ AnnounceRemove(MediaTypeMovie, *it, true);
for (std::vector<int>::const_iterator it = episodeIDs.begin(); it != episodeIDs.end(); ++it)
- AnnounceRemove(MediaTypeEpisode, *it);
+ AnnounceRemove(MediaTypeEpisode, *it, true);
for (std::vector<int>::const_iterator it = tvshowIDs.begin(); it != tvshowIDs.end(); ++it)
- AnnounceRemove(MediaTypeTvShow, *it);
+ AnnounceRemove(MediaTypeTvShow, *it, true);
for (std::vector<int>::const_iterator it = musicVideoIDs.begin(); it != musicVideoIDs.end(); ++it)
- AnnounceRemove(MediaTypeMusicVideo, *it);
+ AnnounceRemove(MediaTypeMusicVideo, *it, true);
}
catch (...)
{
@@ -9158,11 +9157,13 @@ CStdString CVideoDatabase::GetSafeFile(const CStdString &dir, const CStdString &
return URIUtils::AddFileToFolder(dir, CUtil::MakeLegalFileName(safeThumb));
}
-void CVideoDatabase::AnnounceRemove(std::string content, int id)
+void CVideoDatabase::AnnounceRemove(std::string content, int id, bool scanning /* = false */)
{
CVariant data;
data["type"] = content;
data["id"] = id;
+ if (scanning)
+ data["transaction"] = true;
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnRemove", data);
}
View
4 xbmc/video/VideoDatabase.h
@@ -829,6 +829,6 @@ class CVideoDatabase : public CDatabase
std::vector<int> CleanMediaType(const std::string &mediaType, const std::string &cleanableFileIDs,
std::map<int, bool> &pathsDeleteDecisions, std::string &deletedFileIDs, bool silent);
- void AnnounceRemove(std::string content, int id);
- void AnnounceUpdate(std::string content, int id);
+ static void AnnounceRemove(std::string content, int id, bool scanning = false);
+ static void AnnounceUpdate(std::string content, int id);
};
View
5 xbmc/video/VideoInfoScanner.cpp
@@ -1149,7 +1149,10 @@ namespace VIDEO
m_database.Close();
CFileItemPtr itemCopy = CFileItemPtr(new CFileItem(*pItem));
- ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", itemCopy);
+ CVariant data;
+ if (IsScanning())
+ data["transaction"] = true;
+ ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", itemCopy, data);
return lResult;
}
View
17 xbmc/windows/GUIWindowHome.cpp
@@ -34,8 +34,7 @@ using namespace ANNOUNCEMENT;
CGUIWindowHome::CGUIWindowHome(void) : CGUIWindow(WINDOW_HOME, "Home.xml"),
m_recentlyAddedRunning(false),
- m_cumulativeUpdateFlag(0),
- m_dbUpdating(false)
+ m_cumulativeUpdateFlag(0)
{
m_updateRA = (Audio | Video | Totals);
m_loadType = KEEP_IN_MEMORY;
@@ -83,19 +82,11 @@ void CGUIWindowHome::Announce(AnnouncementFlag flag, const char *sender, const c
if ((flag & (VideoLibrary | AudioLibrary)) == 0)
return;
- if (strcmp(message, "OnScanStarted") == 0 ||
- strcmp(message, "OnCleanStarted") == 0)
- {
- m_dbUpdating = true;
+ if (data.isMember("transaction") && data["transaction"].asBoolean())
return;
- }
- if (strcmp(message, "OnScanFinished") == 0 ||
- strcmp(message, "OnCleanFinished") == 0)
- m_dbUpdating = false;
-
- // we are in an update/clean
- if (m_dbUpdating)
+ if (strcmp(message, "OnScanStarted") == 0 ||
+ strcmp(message, "OnCleanStarted") == 0)
return;
bool onUpdate = strcmp(message, "OnUpdate") == 0;
View
1  xbmc/windows/GUIWindowHome.h
@@ -45,5 +45,4 @@ class CGUIWindowHome :
bool m_recentlyAddedRunning;
int m_cumulativeUpdateFlag;
- bool m_dbUpdating;
};
Something went wrong with that request. Please try again.