changeset 471:0dc158c1a6c9

* tidy up uses of CachedFile
author Chris Cannam
date Tue, 28 Oct 2008 11:38:43 +0000
parents dddd4ab77068
children 5015e80cc919
files rdf/PluginRDFDescription.cpp rdf/PluginRDFDescription.h rdf/PluginRDFIndexer.cpp
diffstat 3 files changed, 1 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/rdf/PluginRDFDescription.cpp	Tue Oct 28 11:37:33 2008 +0000
+++ b/rdf/PluginRDFDescription.cpp	Tue Oct 28 11:38:43 2008 +0000
@@ -30,7 +30,6 @@
 using std::endl;
 
 PluginRDFDescription::PluginRDFDescription(QString pluginId) :
-//!!!    m_source(0),
     m_pluginId(pluginId),
     m_haveDescription(false)
 {
@@ -51,7 +50,6 @@
 
 PluginRDFDescription::~PluginRDFDescription()
 {
-//!!!    delete m_source;
 }
 
 bool
@@ -167,25 +165,12 @@
     if (FileSource::isRemote(url) &&
         FileSource::canHandleScheme(url)) {
         
-        //!!! persistent with expiry
-
         CachedFile cf(url);
         if (!cf.isOK()) {
             return false;
         }
 
         local = QUrl::fromLocalFile(cf.getLocalFilename()).toString();
-/*!!!
-        m_source = new FileSource(url, 0, FileSource::PersistentCache);
-
-        if (!m_source->isAvailable()) {
-            delete m_source;
-            m_source = 0;
-            return false;
-        }
-        m_source->waitForData();
-        local = QUrl::fromLocalFile(m_source->getLocalFilename()).toString();
-*/
     }
     
     if (!indexMetadata(local, label)) success = false;
--- a/rdf/PluginRDFDescription.h	Tue Oct 28 11:37:33 2008 +0000
+++ b/rdf/PluginRDFDescription.h	Tue Oct 28 11:38:43 2008 +0000
@@ -20,8 +20,6 @@
 #include <QStringList>
 #include <map>
 
-//!!!class FileSource;
-
 class PluginRDFDescription
 {
 public:
@@ -56,7 +54,6 @@
     typedef std::map<QString, OutputDisposition> OutputDispositionMap;
     typedef std::map<QString, QString> OutputStringMap;
 
-//!!!    FileSource *m_source;
     QString m_pluginId;
     bool m_haveDescription;
     QString m_pluginName;
--- a/rdf/PluginRDFIndexer.cpp	Tue Oct 28 11:37:33 2008 +0000
+++ b/rdf/PluginRDFIndexer.cpp	Tue Oct 28 11:38:43 2008 +0000
@@ -17,8 +17,8 @@
 
 #include "SimpleSPARQLQuery.h"
 
-//!!!#include "data/fileio/FileSource.h"
 #include "data/fileio/CachedFile.h"
+#include "data/fileio/FileSource.h"
 #include "data/fileio/PlaylistFileReader.h"
 #include "plugin/PluginIdentifier.h"
 
@@ -101,12 +101,6 @@
 PluginRDFIndexer::~PluginRDFIndexer()
 {
     QMutexLocker locker(&m_mutex);
-/*!!!
-    while (!m_sources.empty()) {
-        delete *m_sources.begin();
-        m_sources.erase(m_sources.begin());
-    }
-*/
 }
 
 bool
@@ -127,14 +121,6 @@
         std::cerr << "PluginRDFIndexer::indexConfiguredURLs: index url is "
                   << index.toStdString() << std::endl;
 
-/*!!!
-        expireCacheMaybe(index);
-
-        FileSource indexSource(index, 0, FileSource::PersistentCache);
-        if (!indexSource.isAvailable()) continue;
-        indexSource.waitForData();
-*/
-
         CachedFile cf(index);
         if (!cf.isOK()) continue;
 
@@ -239,43 +225,7 @@
     QString urlString = url.toString();
     return indexURL(urlString);
 }
-/*!!!
-void
-PluginRDFIndexer::expireCacheMaybe(QString urlString)
-{
-    QString cacheFile = FileSource::getPersistentCacheFilePath(urlString);
 
-    QSettings settings;
-    settings.beginGroup("RDF");
-
-    QString key("rdf-expiry-times");
-
-    QMap<QString, QVariant> expiryMap = settings.value(key).toMap();
-    QDateTime lastExpiry = expiryMap[urlString].toDateTime();
-
-    if (!QFileInfo(cacheFile).exists()) {
-        expiryMap[urlString] = QDateTime::currentDateTime();
-        settings.setValue(key, expiryMap);
-        settings.endGroup();
-        return;
-    }
-
-    if (!lastExpiry.isValid() ||
-        (lastExpiry.addDays(2) < QDateTime::currentDateTime())) {
-
-        std::cerr << "Expiring old cache file " << cacheFile.toStdString()
-                  << std::endl;
-
-        if (QFile(cacheFile).remove()) {
-
-            expiryMap[urlString] = QDateTime::currentDateTime();
-            settings.setValue(key, expiryMap);
-        }
-    }
-
-    settings.endGroup();
-}
-*/
 bool
 PluginRDFIndexer::indexURL(QString urlString)
 {
@@ -290,28 +240,12 @@
     if (FileSource::isRemote(urlString) &&
         FileSource::canHandleScheme(urlString)) {
 
-        //!!! how do we avoid hammering the server if it doesn't have
-        //!!! the file, and/or the network if it can't get through?
-
         CachedFile cf(urlString);
         if (!cf.isOK()) {
             return false;
         }
 
         localString = cf.getLocalFilename();
-/*!!!
-        expireCacheMaybe(urlString);
-
-        FileSource *source = new FileSource
-            (urlString, 0, FileSource::PersistentCache);
-        if (!source->isAvailable()) {
-            delete source;
-            return false;
-        }
-        source->waitForData();
-        localString = QUrl::fromLocalFile(source->getLocalFilename()).toString();
-        m_sources.insert(source);
-*/
     }
 
 //    cerr << "PluginRDFIndexer::indexURL: url = <" << urlString.toStdString() << ">" << endl;