Skip to content
Browse files

add upgrade path for existing libraries

  • Loading branch information...
1 parent cf027b1 commit 3b0e9b477312a8cbb8e73960463d82be4184d8e0 Jonathan Marshall committed Jan 27, 2012
Showing with 18 additions and 5 deletions.
  1. +13 −1 xbmc/video/VideoDatabase.cpp
  2. +5 −4 xbmc/video/VideoDatabase.h
View
14 xbmc/video/VideoDatabase.cpp
@@ -3485,6 +3485,17 @@ bool CVideoDatabase::UpdateOldVersion(int iVersion)
m_pDS->exec("UPDATE settings SET DeinterlaceMode = 0, Deinterlace = 1 WHERE Deinterlace = 0"); // method none => mode off, method auto
}
+ if (iVersion < 59)
+ { // base paths for video_ts and bdmv files was wrong (and inconsistent depending on where and when they were scanned)
+ CStdString where = PrepareSQL(" WHERE files.strFileName LIKE 'VIDEO_TS.IFO' or files.strFileName LIKE 'index.BDMV'");
+ UpdateBasePath("movie", "idMovie", VIDEODB_ID_BASEPATH, false, where);
+ UpdateBasePath("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH, false, where);
+ UpdateBasePath("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH, false, where);
+ UpdateBasePathID("movie", "idMovie", VIDEODB_ID_BASEPATH, VIDEODB_ID_PARENTPATHID);
+ UpdateBasePathID("musicvideo", "idMVideo", VIDEODB_ID_MUSICVIDEO_BASEPATH, VIDEODB_ID_MUSICVIDEO_PARENTPATHID);
+ UpdateBasePathID("episode", "idEpisode", VIDEODB_ID_EPISODE_BASEPATH, VIDEODB_ID_EPISODE_PARENTPATHID);
+ }
+
// always recreate the view after any table change
CreateViews();
}
@@ -3508,13 +3519,14 @@ bool CVideoDatabase::LookupByFolders(const CStdString &path, bool shows)
return settings.parent_name_root; // shows, movies, musicvids
}
-void CVideoDatabase::UpdateBasePath(const char *table, const char *id, int column, bool shows)
+void CVideoDatabase::UpdateBasePath(const char *table, const char *id, int column, bool shows, const CStdString &where)
{
CStdString query;
if (shows)
query = PrepareSQL("SELECT idShow,path.strPath from tvshowlinkpath join path on tvshowlinkpath.idPath=path.idPath");
else
query = PrepareSQL("SELECT %s.%s,path.strPath,files.strFileName from %s join files on %s.idFile=files.idFile join path on files.idPath=path.idPath", table, id, table, table);
+ query += where;
map<CStdString, bool> paths;
m_pDS2->query(query.c_str());
View
9 xbmc/video/VideoDatabase.h
@@ -698,16 +698,17 @@ class CVideoDatabase : public CDatabase
int RunQuery(const CStdString &sql);
/*! \brief Update routine for base path of videos
- Only required for videodb version < 44
+ Only required for videodb version < 59
\param table the table to update
\param id the primary id in the given table
\param column the basepath column to update
\param shows whether we're fetching shows (defaults to false)
+ \param where restrict updating of items that match the where clause
*/
- void UpdateBasePath(const char *table, const char *id, int column, bool shows = false);
+ void UpdateBasePath(const char *table, const char *id, int column, bool shows = false, const CStdString &where = "");
/*! \brief Update routine for base path id of videos
- Only required for videodb version < 52
+ Only required for videodb version < 59
\param table the table to update
\param id the primary id in the given table
\param column the column of the basepath
@@ -721,7 +722,7 @@ class CVideoDatabase : public CDatabase
*/
bool LookupByFolders(const CStdString &path, bool shows = false);
- virtual int GetMinVersion() const { return 58; };
+ virtual int GetMinVersion() const { return 59; };
virtual int GetExportVersion() const { return 1; };
const char *GetBaseDBName() const { return "MyVideos"; };

0 comments on commit 3b0e9b4

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