Skip to content

Commit

Permalink
Music database: Keep protocol options as part of path
Browse files Browse the repository at this point in the history
URIUtils::Split now removes protocol options, and not adding them
to the path would cause them to get lost when the path from the
database is used directly.
  • Loading branch information
pkerling committed Jul 9, 2018
1 parent 4b95bae commit 67f57ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions xbmc/filesystem/CurlFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ void CCurlFile::SetCommonOptions(CReadState* state, bool failOnError /* = true *
state->m_curlAliasList = g_curlInterface.slist_append(state->m_curlAliasList, "ICY 200 OK");
g_curlInterface.easy_setopt(h, CURLOPT_HTTP200ALIASES, state->m_curlAliasList);

if (m_verifyPeer)
{
CLog::Log(LOGDEBUG, "Verifying peer");
}

if (!m_verifyPeer)
g_curlInterface.easy_setopt(h, CURLOPT_SSL_VERIFYPEER, 0);

Expand Down
19 changes: 15 additions & 4 deletions xbmc/music/MusicDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ void CMusicDatabase::CreateViews()
" song_artist.idRole = role.idRole");
}

void CMusicDatabase::SplitPath(const std::string& strFileNameAndPath, std::string& strPath, std::string& strFileName)
{
URIUtils::Split(strFileNameAndPath, strPath, strFileName);
// Keep protocol options as part of the path
if (URIUtils::IsURL(strFileNameAndPath))
{
CURL url(strFileNameAndPath);
strPath += "|" + url.GetProtocolOptions();
}
}

bool CMusicDatabase::AddAlbum(CAlbum& album, int idSource)
{
BeginTransaction();
Expand Down Expand Up @@ -564,7 +575,7 @@ int CMusicDatabase::AddSong(const int idAlbum,
if (NULL == m_pDS.get()) return -1;

std::string strPath, strFileName;
URIUtils::Split(strPathAndFileName, strPath, strFileName);
SplitPath(strPathAndFileName, strPath, strFileName);
int idPath = AddPath(strPath);

if (!strMusicBrainzTrackID.empty())
Expand Down Expand Up @@ -760,7 +771,7 @@ int CMusicDatabase::UpdateSong(int idSong,

std::string strSQL;
std::string strPath, strFileName;
URIUtils::Split(strPathAndFileName, strPath, strFileName);
SplitPath(strPathAndFileName, strPath, strFileName);
int idPath = AddPath(strPath);

strSQL = PrepareSQL("UPDATE song SET idPath = %i, strArtistDisp = '%s', strGenres = '%s', "
Expand Down Expand Up @@ -2337,7 +2348,7 @@ bool CMusicDatabase::GetSongByFileName(const std::string& strFileNameAndPath, CS
if (NULL == m_pDS.get()) return false;

std::string strPath, strFileName;
URIUtils::Split(strFileNameAndPath, strPath, strFileName);
SplitPath(strFileNameAndPath, strPath, strFileName);
URIUtils::AddSlashAtEnd(strPath);

std::string strSQL = PrepareSQL("select idSong from songview "
Expand Down Expand Up @@ -7342,7 +7353,7 @@ int CMusicDatabase::GetSongIDFromPath(const std::string &filePath)
if (NULL == m_pDS.get()) return -1;

std::string strPath, strFileName;
URIUtils::Split(filePath, strPath, strFileName);
SplitPath(filePath, strPath, strFileName);
URIUtils::AddSlashAtEnd(strPath);

std::string sql = PrepareSQL("select idSong from song join path on song.idPath = path.idPath where song.strFileName='%s' and path.strPath='%s'", strFileName.c_str(), strPath.c_str());
Expand Down
2 changes: 2 additions & 0 deletions xbmc/music/MusicDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ void SetLibraryLastUpdated();
*/
virtual void CreateViews();

void SplitPath(const std::string& strFileNameAndPath, std::string& strPath, std::string& strFileName);

CSong GetSongFromDataset();
CSong GetSongFromDataset(const dbiplus::sql_record* const record, int offset = 0);
CArtist GetArtistFromDataset(dbiplus::Dataset* pDS, int offset = 0, bool needThumb = true);
Expand Down

0 comments on commit 67f57ef

Please sign in to comment.