2016-06-14, 21:25
Adding a file to the queue using a file item parameter adds the items twice to the queue if the song has been scanned into the music database
It fails in CFileItemHandler::FillFileItemList(const CVariant ¶meterObject, CFileItemList &list) when doing the following check
The left side contains the resolved internal musicdb:// path and the right side the file name so it will obviously fail and add the file twice
Code:
{"id":1,"jsonrpc":"2.0","method":"Playlist.Add","params":{"item":{"file":"/media/Music/Pop/Lovebugs - In Every Waking Moment - 2006/01 - Lovebugs - Tonight.mp3"},"playlistid":0}}"
It fails in CFileItemHandler::FillFileItemList(const CVariant ¶meterObject, CFileItemList &list) when doing the following check
Code:
if (list[index]->GetPath() == file)
The left side contains the resolved internal musicdb:// path and the right side the file name so it will obviously fail and add the file twice
Code:
bool CFileItemHandler::FillFileItemList(const CVariant ¶meterObject, CFileItemList &list)
{
CAudioLibrary::FillFileItemList(parameterObject, list);
CVideoLibrary::FillFileItemList(parameterObject, list);
CFileOperations::FillFileItemList(parameterObject, list);
std::string file = parameterObject["file"].asString();
if (!file.empty() && (URIUtils::IsURL(file) || (CFile::Exists(file) && !CDirectory::Exists(file))))
{
bool added = false;
for (int index = 0; index < list.Size(); index++)
{
if (list[index]->GetPath() == file)
{
added = true;
break;
}
}
if (!added)
{
CFileItemPtr item = CFileItemPtr(new CFileItem(file, false));
if (item->IsPicture())
{
CPictureInfoTag picture;
picture.Load(item->GetPath());
*item->GetPictureInfoTag() = picture;
}
if (item->GetLabel().empty())
{
item->SetLabel(CUtil::GetTitleFromPath(file, false));
if (item->GetLabel().empty())
item->SetLabel(URIUtils::GetFileName(file));
}
list.Add(item);
}
}
return (list.Size() > 0);
}