Skip to content

Commit

Permalink
Merge pull request xbmc#23939 from ksooo/fileitem-fix-mimetype-update
Browse files Browse the repository at this point in the history
[fileitem] Fix mimetype not set/updated properly on loading details.
  • Loading branch information
ksooo authored Oct 15, 2023
2 parents 8fd6170 + 1a1660e commit e620c50
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
21 changes: 16 additions & 5 deletions xbmc/FileItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,16 @@ void CFileItem::FillInMimeType(bool lookup /*= true*/)
}
}

void CFileItem::UpdateMimeType(bool lookup /*= true*/)
{
//! @todo application/octet-stream might actually have been set by a web lookup. Currently we
//! cannot distinguish between set as fallback only (see FillInMimeType) or as an actual value.
if (m_mimetype == "application/octet-stream")
m_mimetype.clear();

FillInMimeType(lookup);
}

void CFileItem::SetMimeTypeForInternetFile()
{
if (m_doContentLookup && IsInternetStream())
Expand Down Expand Up @@ -1768,6 +1778,7 @@ void CFileItem::UpdateInfo(const CFileItem &item, bool replaceLabels /*=true*/)
if (!item.GetArt().empty())
SetArt(item.GetArt());
AppendProperties(item);
UpdateMimeType();
}

void CFileItem::MergeInfo(const CFileItem& item)
Expand Down Expand Up @@ -1836,6 +1847,7 @@ void CFileItem::MergeInfo(const CFileItem& item)
SetArt(item.GetArt());
}
AppendProperties(item);
UpdateMimeType();
}

void CFileItem::SetFromVideoInfoTag(const CVideoInfoTag &video)
Expand Down Expand Up @@ -3781,10 +3793,9 @@ bool CFileItem::LoadDetails()

if (ret)
{
m_videoInfoTag = tag.release();
m_strDynPath = m_videoInfoTag->m_strFileNameAndPath;
const CFileItem loadedItem{*tag};
UpdateInfo(loadedItem);
}

return ret;
}

Expand Down Expand Up @@ -3816,8 +3827,8 @@ bool CFileItem::LoadDetails()
auto tag{std::make_unique<CVideoInfoTag>()};
if (db.LoadVideoInfo(GetDynPath(), *tag))
{
m_videoInfoTag = tag.release();
m_strDynPath = m_videoInfoTag->m_strFileNameAndPath;
const CFileItem loadedItem{*tag};
UpdateInfo(loadedItem);
return true;
}

Expand Down
6 changes: 6 additions & 0 deletions xbmc/FileItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,12 @@ class CFileItem :
*/
void Initialize();

/*! \brief Recalculate item's MIME type if it is not set or is set to "application/octet-stream".
Resolve the MIME type based on file extension or a web lookup.
\sa FillInMimeType
*/
void UpdateMimeType(bool lookup = true);

/*!
\brief Return the current resume point for this item.
\return The resume point.
Expand Down

0 comments on commit e620c50

Please sign in to comment.