Ticket #12424: 0005-Cache-FE-gallery-images-in-remotecache-for-Minimyth2.patch

File 0005-Cache-FE-gallery-images-in-remotecache-for-Minimyth2.patch, 3.5 KB (added by dizygotheca@…, 5 years ago)

Minimyth2 customisation

  • mythtv/libs/libmythui/mythuihelper.cpp

    From 0c9f98bb8889878194a7340139a3fe837155217e Mon Sep 17 00:00:00 2001
    From: Roger Siddons <dizygotheca@ntlworld.com>
    Date: Wed, 29 Apr 2015 14:41:23 +0100
    Subject: [PATCH] Cache FE gallery images in remotecache for Minimyth2
    
    
    diff --git a/mythtv/libs/libmythui/mythuihelper.cpp b/mythtv/libs/libmythui/mythuihelper.cpp
    index 19e73e7..4ec6e86 100644
    a b MythImage *MythUIHelper::CacheImage(const QString &url, MythImage *im, 
    590590
    591591    if (!nodisk)
    592592    {
    593         QString dstfile = GetMythUI()->GetThemeCacheDir() + '/' + url;
     593        QString cachedir = GetMythUI()->GetThemeCacheDir(url);
     594        QString dstfile = cachedir + '/' + url;
    594595
    595596        LOG(VB_GUI | VB_FILE, LOG_INFO, LOC +
    596597            QString("Saved to Cache (%1)").arg(dstfile));
    597598
    598599        // This would probably be better off somewhere else before any
    599600        // Load() calls at all.
    600         QDir themedir(GetMythUI()->GetThemeCacheDir());
    601 
    602         if (!themedir.exists())
    603             themedir.mkdir(GetMythUI()->GetThemeCacheDir());
     601        QDir themedir(cachedir);
     602        themedir.mkdir(cachedir);
    604603
    605604        // Save to disk cache
    606605        im->save(dstfile, "PNG");
    void MythUIHelper::RemoveFromCacheByURL(const QString &url) 
    691690
    692691    QString dstfile;
    693692
    694     dstfile = GetThemeCacheDir() + '/' + url;
     693    dstfile = GetThemeCacheDir(url) + '/' + url;
    695694    LOG(VB_GUI | VB_FILE, LOG_INFO, LOC +
    696695        QString("RemoveFromCacheByURL removed :%1: from cache").arg(dstfile));
    697696    QFile::remove(dstfile);
    void MythUIHelper::RemoveFromCacheByFile(const QString &fname) 
    716715
    717716    // Loop through files to cache any that were not caught by
    718717    // RemoveFromCacheByURL
    719     QDir dir(GetThemeCacheDir());
     718    QDir dir(GetThemeCacheDir(partialKey));
    720719    QFileInfoList list = dir.entryInfoList();
    721720
    722721    for (int i = 0; i < list.size(); ++i)
    bool MythUIHelper::IsImageInCache(const QString &url) 
    750749    return false;
    751750}
    752751
    753 QString MythUIHelper::GetThemeCacheDir(void)
     752QString MythUIHelper::GetThemeCacheDir(const QString &mrl)
    754753{
     754    // Gallery thumbnails ("-Photographs-") and images ("-Photographs@") are cached separately
     755    if (mrl.contains("-Photographs"))
     756        return GetConfDir() + "/cache/remotecache/";
     757
    755758    QString cachedirname = GetConfDir() + "/cache/themecache/";
    756759
    757760    QString tmpcachedir = cachedirname +
    MythImage *MythUIHelper::LoadCacheImage(QString srcfile, QString label, 
    16041607    if (ret || !(cacheMode & kCacheIgnoreDisk))
    16051608    {
    16061609        // Create url to image in disk cache
    1607         QString cachefilepath = GetThemeCacheDir() + '/' + label;
     1610        QString cachefilepath = GetThemeCacheDir(label) + '/' + label;
    16081611        QFileInfo cacheFileInfo(cachefilepath);
    16091612
    16101613        // If the file isn't in the disk cache, then we don't want to bother
  • mythtv/libs/libmythui/mythuihelper.h

    diff --git a/mythtv/libs/libmythui/mythuihelper.h b/mythtv/libs/libmythui/mythuihelper.h
    index 759dd7f..e64d007 100644
    a b class MUI_PUBLIC MythUIHelper 
    5757    void RemoveFromCacheByURL(const QString &url);
    5858    void RemoveFromCacheByFile(const QString &fname);
    5959    bool IsImageInCache(const QString &url);
    60     QString GetThemeCacheDir(void);
     60    QString GetThemeCacheDir(const QString &mrl = "");
    6161
    6262    void IncludeInCacheSize(MythImage *im);
    6363    void ExcludeFromCacheSize(MythImage *im);