Skip to content
This repository
Browse code

[musicdb] fix: db updates fail due to duplicate keys creating unique …

…indexes for musicbrainz
  • Loading branch information...
commit a0dbc673b7f01b1c58295b4fdcbee2feeadbc0ff 1 parent 6deaf5f
night199uk authored May 02, 2013
3  xbmc/music/MusicDatabase.cpp
@@ -3727,6 +3727,7 @@ bool CMusicDatabase::UpdateOldVersion(int version)
3727 3727
     m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
3728 3728
     m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
3729 3729
 
  3730
+    m_pDS->exec("UPDATE song SET strMusicBrainzTrackID = NULL where strMusicBrainzTrackID = ''");
3730 3731
     m_pDS->exec("CREATE UNIQUE INDEX idxArtist1 ON artist(strMusicBrainzArtistID(36))");
3731 3732
   }
3732 3733
 
@@ -3736,6 +3737,8 @@ bool CMusicDatabase::UpdateOldVersion(int version)
3736 3737
     m_pDS->exec("CREATE UNIQUE INDEX idxSong7 ON song( idAlbum, strMusicBrainzTrackID(36) )");
3737 3738
     m_pDS->exec("ALTER TABLE album_artist ADD strJoinPhrase text\n");
3738 3739
     m_pDS->exec("ALTER TABLE song_artist ADD strJoinPhrase text\n");
  3740
+    CMediaSettings::Get().SetMusicNeedsUpdate(35);
  3741
+    CSettings::Get().Save();
3739 3742
   }
3740 3743
 
3741 3744
   // always recreate the views after any table change
9  xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -1142,13 +1142,18 @@ bool CGUIWindowMusicBase::CanContainFilter(const CStdString &strDirectory) const
1142 1142
 void CGUIWindowMusicBase::OnInitWindow()
1143 1143
 {
1144 1144
   CGUIMediaWindow::OnInitWindow();
1145  
-  if (CMediaSettings::Get().GetMusicNeedsUpdate() == 27 && !g_application.IsMusicScanning() &&
  1145
+  if (CMediaSettings::Get().GetMusicNeedsUpdate() == 35 && !g_application.IsMusicScanning() &&
1146 1146
       g_infoManager.GetLibraryBool(LIBRARY_HAS_MUSIC))
1147 1147
   {
1148 1148
     // rescan of music library required
1149 1149
     if (CGUIDialogYesNo::ShowAndGetInput(799, 800, 801, -1))
1150 1150
     {
1151  
-      g_application.StartMusicScan("", CMusicInfoScanner::SCAN_RESCAN);
  1151
+      int flags = CMusicInfoScanner::SCAN_RESCAN;
  1152
+      if (CSettings::Get().GetBool("musiclibrary.downloadinfo"))
  1153
+        flags |= CMusicInfoScanner::SCAN_ONLINE;
  1154
+      if (CSettings::Get().GetBool("musiclibrary.backgroundupdate"))
  1155
+        flags |= CMusicInfoScanner::SCAN_BACKGROUND;
  1156
+      g_application.StartMusicScan("", flags);
1152 1157
       CMediaSettings::Get().SetMusicNeedsUpdate(0); // once is enough (user may interrupt, but that's up to them)
1153 1158
       CSettings::Get().Save();
1154 1159
     }

0 notes on commit a0dbc67

jmarshallnz

Is there really no other solution to this bug than a complete rescan, including online? This should be a last resort.

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