videodb: translate filenames/paths to not URL encode -_.!() (fixes #13433)
authormontellese <montellese@xbmc.org>
Tue, 30 Oct 2012 14:10:19 +0000 (15:10 +0100)
committermontellese <montellese@xbmc.org>
Wed, 31 Oct 2012 08:11:01 +0000 (09:11 +0100)
xbmc/video/VideoDatabase.cpp
xbmc/video/VideoDatabase.h

index 4b41a5d..6064b66 100644 (file)
@@ -4124,6 +4124,24 @@ bool CVideoDatabase::UpdateOldVersion(int iVersion)
     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 (iVersion < 71)
+  { // update URL encoded paths
+    m_pDS->query("select idFile, strFilename from files");
+    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 files SET strFilename='%s' WHERE idFile=%d", filename.c_str(), i->first));
+    }
+  }
   // always recreate the view after any table change
   CreateViews();
   return true;
index 74a38ff..3a6400b 100644 (file)
@@ -804,7 +804,7 @@ private:
    */
   bool LookupByFolders(const CStdString &path, bool shows = false);
 
-  virtual int GetMinVersion() const { return 70; };
+  virtual int GetMinVersion() const { return 71; };
   virtual int GetExportVersion() const { return 1; };
   const char *GetBaseDBName() const { return "MyVideos"; };