Skip to content
Browse files

[musicdb] make the song path index unique on path + filename

  • Loading branch information...
1 parent dcebded commit a54ee886fb39386ea011aa6e0861d27a0ceaee83 @night199uk committed Jul 3, 2012
Showing with 8 additions and 2 deletions.
  1. +7 −1 xbmc/music/MusicDatabase.cpp
  2. +1 −1 xbmc/music/MusicDatabase.h
View
8 xbmc/music/MusicDatabase.cpp
@@ -163,7 +163,7 @@ bool CMusicDatabase::CreateTables()
CLog::Log(LOGINFO, "create song index3");
m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
CLog::Log(LOGINFO, "create song index6");
- m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
+ m_pDS->exec("CREATE UNIQUE INDEX idxSong6 ON song( idPath, strFileName(255) )");
CLog::Log(LOGINFO, "create song_artist indexes");
m_pDS->exec("CREATE UNIQUE INDEX idxSongArtist_1 ON song_artist ( idSong, idArtist )\n");
@@ -3563,6 +3563,12 @@ bool CMusicDatabase::UpdateOldVersion(int version)
m_pDS->exec(PrepareSQL("DELETE FROM karaokedata WHERE iKaraNumber = %d", g_advancedSettings.m_karaokeStartIndex - 1));
}
+ if (version < 29)
+ {
+ m_pDS->exec("DROP INDEX idxSong6 ON song");
+ m_pDS->exec("CREATE UNIQUE INDEX idxSong6 on song( idPath, strFileName(255) )");
+ }
+
// always recreate the views after any table change
CreateViews();
View
2 xbmc/music/MusicDatabase.h
@@ -280,7 +280,7 @@ class CMusicDatabase : public CDatabase
std::map<CStdString, CAlbum> m_albumCache;
virtual bool CreateTables();
- virtual int GetMinVersion() const { return 28; };
+ virtual int GetMinVersion() const { return 29; };
const char *GetBaseDBName() const { return "MyMusic"; };
int AddSong(const CSong& song, bool bCheck = true, int idAlbum = -1);

0 comments on commit a54ee88

Please sign in to comment.
Something went wrong with that request. Please try again.