All pastes #578421 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-20 08:52 UTC
rendered paste body
Index: programs/mythfilldatabase/filldata.cpp
===================================================================
--- programs/mythfilldatabase/filldata.cpp	(revision 13751)
+++ programs/mythfilldatabase/filldata.cpp	(working copy)
@@ -264,7 +264,8 @@
     QString home = QDir::homeDirPath();
     QString configfile = QString("%1/%2.xmltv").arg(MythContext::GetConfDir())
                                                        .arg(source.name);
-
+    QString cachefile = QString("%1/%2.cache").arg(MythContext::GetConfDir())
+                                              .arg(source.name);
     QString command  = QString("nice %1 --config-file '%2' --output %3")
                             .arg(xmltv_grabber.ascii())
                             .arg(configfile.ascii())
@@ -289,6 +290,9 @@
     if (! (print_verbose_messages & VB_XMLTV))
         command += " --quiet";
 
+    if (source.xmltvgrabber_cache)
+        command += QString(" --cache %1").arg(cachefile.ascii());
+
     QDateTime qdtNow = QDateTime::currentDateTime();
     MSqlQuery query(MSqlQuery::InitCon());
     QString status = "currently running.";
@@ -564,7 +568,43 @@
                         .arg(xmltv_grabber));
             }
         }
+        if ((*it).xmltvgrabber_cache)
+        {
+            QString cachefile = QString("%1/%2_cache.conf")
+                    .arg(MythContext::GetConfDir())
+                    .arg((*it).name);
 
+            QFile file(cachefile);
+            if (!file.exists())
+            {
+                QString cachedir = QString("%1/%2_cache")
+                                        .arg(MythContext::GetConfDir())
+                                        .arg((*it).name);
+
+                if (file.open(IO_WriteOnly))
+                {
+                    QTextStream stream(&file);
+                    stream << "BasePath " << cachedir << "\n";
+                    stream << "Verbose 1" << "\n";
+                    file.close();
+                }
+                else
+                {
+                    VERBOSE(VB_IMPORTANT, QString("Creating cache config, "
+                        "%1, failed.").arg(cachedir));
+                    (*it).xmltvgrabber_cache = false;
+                }
+
+                QDir dir(cachedir);
+                if (!dir.exists() && !dir.mkdir(dir.path()))
+                {
+                    VERBOSE(VB_IMPORTANT, QString("Creating cache directory, "
+                        "%1, failed.").arg(cachedir));
+                    (*it).xmltvgrabber_cache = false;
+                }
+            }
+        }
+
         need_post_grab_proc |= (xmltv_grabber != "datadirect");
 
         if ((xmltv_grabber == "datadirect") && dd_grab_all)