Permalink
Browse files

musicdb: translate filenames/paths to not URL encode -_.!()

  • Loading branch information...
Montellese committed Oct 30, 2012
1 parent 37bdff8 commit a14a1c9d3b1ed8792f866d8861a8a4355617afe3
Showing with 19 additions and 1 deletion.
  1. +18 −0 xbmc/music/MusicDatabase.cpp
  2. +1 −1 xbmc/music/MusicDatabase.h
@@ -3649,6 +3649,24 @@ bool CMusicDatabase::UpdateOldVersion(int version)
for (vector< pair<int, string> >::iterator i = art.begin(); i != art.end(); ++i)
m_pDS->exec(PrepareSQL("update art set url='%s' where art_id=%d", i->second.c_str(), i->first));
}
if (version < 30)
{ // update URL encoded paths
m_pDS->query("select idSong, strFileName from song");
vector< pair<int, string> > files;
while (!m_pDS->eof())
{
files.push_back(make_pair(m_pDS->fv(0).get_asInt(), m_pDS->fv(1).get_asString()));
m_pDS->next();
}
m_pDS->close();

for (vector< pair<int, string> >::iterator i = files.begin(); i != files.end(); ++i)
{
std::string filename = i->second;
if (URIUtils::UpdateUrlEncoding(filename))
m_pDS->exec(PrepareSQL("UPDATE song SET strFileName='%s' WHERE idSong=%d", filename.c_str(), i->first));
}
}
// always recreate the views after any table change
CreateViews();

@@ -278,7 +278,7 @@ class CMusicDatabase : public CDatabase
std::map<CStdString, CAlbum> m_albumCache;

virtual bool CreateTables();
virtual int GetMinVersion() const { return 29; };
virtual int GetMinVersion() const { return 30; };
const char *GetBaseDBName() const { return "MyMusic"; };

int AddSong(const CSong& song, bool bCheck = true, int idAlbum = -1);

0 comments on commit a14a1c9

Please sign in to comment.