Repository: xbmc/xbmc
File: xbmc/utils/SaveFileStateJob.cpp (C++)

Code before:
        {
          CFileItem dbItem(item);

          // Check whether the item's db streamdetails need updating
          if (!videodatabase.GetStreamDetails(dbItem) ||
              dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
          {
            videoDbSuccess = videodatabase.SetStreamDetailsForFile(
                item.GetVideoInfoTag()->m_streamDetails, progressTrackingFile);
            updateListing = !videoDbSuccess;
          }
        }

        // See if fileId needs updating
        if (URIUtils::IsBlurayPath(item.GetDynPath()))
        {
          if (item.GetVideoContentType() == VideoDbContentType::MOVIES)
          {
            const auto& tag{item.GetVideoInfoTag()};
            const int currentFileId{videodatabase.GetFileIdByMovie(tag->m_iDbId)};
            if (tag->m_strFileNameAndPath != item.GetDynPath())
              videoDbSuccess |= videodatabase.SetFileForMovie(item.GetDynPath(), currentFileId);
          }
          else if (item.GetVideoContentType() == VideoDbContentType::EPISODES)
          {
            const auto& tag{item.GetVideoInfoTag()};
            const int currentFileId{videodatabase.GetFileIdByEpisode(tag->m_iDbId)};
            if (tag->m_strFileNameAndPath != item.GetDynPath())
              videoDbSuccess |= videodatabase.SetFileForEpisode(
                  item.GetDynPath(), item.GetVideoInfoTag()->m_iDbId, currentFileId);
          }
        }

        if (videoDbSuccess)
          videodatabase.CommitTransaction();
        else
          videodatabase.RollbackTransaction();

        if (updateListing)
        {
          CUtil::DeleteVideoDatabaseDirectoryCache();
          CFileItemPtr msgItem(new CFileItem(item));
          if (item.HasProperty("original_listitem_url"))
            msgItem->SetPath(item.GetProperty("original_listitem_url").asString());

          // Could be part of an ISO stack. In this case the bookmark is saved onto the part.
          // In order to properly update the list, we need to refresh the stack's resume point
          const auto& components = CServiceBroker::GetAppComponents();
          const auto stackHelper = components.GetComponent<CApplicationStackHelper>();
          if (stackHelper->HasRegisteredStack(item) &&
              stackHelper->GetRegisteredStackTotalTimeMs(item) == 0)

Review comment (suggestion):
`item.GetVideoInfoTag()` returns a pointer, not a reference. Please change to `const CVideoInfoTag*` to be explicit. `auto` imo here is just for the lazy, but decreases code readability.

Code after:
          videodatabase.CommitTransaction();
        else
          videodatabase.RollbackTransaction();
        videodatabase.BeginTransaction();

        if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->HasStreamDetails() &&
            !item.IsLiveTV())
        {
          CFileItem dbItem(item);

          // Check whether the item's db streamdetails need updating
          if (!videodatabase.GetStreamDetails(dbItem) ||
              dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails)
          {
            videoDbSuccess = videodatabase.SetStreamDetailsForFile(
                item.GetVideoInfoTag()->m_streamDetails, progressTrackingFile);
            updateListing = !videoDbSuccess;
          }
        }

        if (videoDbSuccess)
          videodatabase.CommitTransaction();
        else
          videodatabase.RollbackTransaction();
        videodatabase.BeginTransaction();
        videoDbSuccess = true;

        // See if idFile needs updating
        if (item.HasVideoInfoTag() && URIUtils::IsBlurayPath(item.GetDynPath()))
        {
          if (item.GetVideoContentType() == VideoDbContentType::MOVIES)
          {
            const CVideoInfoTag* tag{item.GetVideoInfoTag()};
            if (tag->m_strFileNameAndPath != item.GetDynPath())
              // tag->m_iFileId contains the idFile played and may be different to the idFile in the movie table entry if it's
              // a non-default video version
              videoDbSuccess =
                  videodatabase.SetFileForMovie(item.GetDynPath(), tag->m_iDbId, tag->m_iFileId);
          }
          else if (item.GetVideoContentType() == VideoDbContentType::EPISODES)
          {
            const CVideoInfoTag* tag{item.GetVideoInfoTag()};
            if (tag->m_strFileNameAndPath != item.GetDynPath())
              videoDbSuccess =
                  videodatabase.SetFileForEpisode(item.GetDynPath(), tag->m_iDbId, tag->m_iFileId);
          }
        }

        if (videoDbSuccess)
          videodatabase.CommitTransaction();
        else