# HG changeset patch # User Chris Cannam # Date 1225139395 0 # Node ID 70b333085952a13b26ea7613512ad63fe3583e0f # Parent c9b055f843265ecb328d8885a494c6cd022a9adc * complete switching the code to use CachedFile -- now to tidy & fix the remaining flaws... diff -r c9b055f84326 -r 70b333085952 data/fileio/CachedFile.cpp --- a/data/fileio/CachedFile.cpp Mon Oct 27 18:15:20 2008 +0000 +++ b/data/fileio/CachedFile.cpp Mon Oct 27 20:29:55 2008 +0000 @@ -61,20 +61,20 @@ return fi.filePath(); } -CachedFile::CachedFile(QString url, ProgressReporter *reporter) : - m_url(url), - m_localFilename(getLocalFilenameFor(m_url)), +CachedFile::CachedFile(QString origin, ProgressReporter *reporter) : + m_origin(origin), + m_localFilename(getLocalFilenameFor(m_origin)), m_reporter(reporter), m_ok(false) { - std::cerr << "CachedFile::CachedFile: url is \"" - << url.toStdString() << "\"" << std::endl; + std::cerr << "CachedFile::CachedFile: origin is \"" + << origin.toStdString() << "\"" << std::endl; check(); } CachedFile::CachedFile(QUrl url, ProgressReporter *reporter) : - m_url(url), - m_localFilename(getLocalFilenameFor(m_url)), + m_origin(url.toString()), + m_localFilename(getLocalFilenameFor(m_origin)), m_reporter(reporter), m_ok(false) { @@ -160,15 +160,17 @@ //!!! using Qt classes, but a plain delete then copy is probably //!!! good enough) - FileSource fs(m_url, m_reporter); + FileSource fs(m_origin, m_reporter); if (!fs.isOK() || !fs.isAvailable()) { + std::cerr << "CachedFile::retrieve: ERROR: FileSource reported unavailable or failure" << std::endl; return false; } fs.waitForData(); if (!fs.isOK()) { + std::cerr << "CachedFile::retrieve: ERROR: FileSource reported failure during receive" << std::endl; return false; } @@ -196,6 +198,8 @@ return false; } + std::cerr << "CachedFile::retrieve: Successfully copied newly retrieved file \"" << tempName.toStdString() << "\" to its home at \"" << m_localFilename.toStdString() << "\"" << std::endl; + return true; } diff -r c9b055f84326 -r 70b333085952 data/fileio/CachedFile.h --- a/data/fileio/CachedFile.h Mon Oct 27 18:15:20 2008 +0000 +++ b/data/fileio/CachedFile.h Mon Oct 27 20:29:55 2008 +0000 @@ -35,7 +35,7 @@ QString getLocalFilename() const; protected: - QUrl m_url; + QString m_origin; QString m_localFilename; ProgressReporter *m_reporter; bool m_ok; diff -r c9b055f84326 -r 70b333085952 data/fileio/FileSource.cpp --- a/data/fileio/FileSource.cpp Mon Oct 27 18:15:20 2008 +0000 +++ b/data/fileio/FileSource.cpp Mon Oct 27 20:29:55 2008 +0000 @@ -62,6 +62,12 @@ m_reporter(reporter), m_refCounted(false) { + + if (cacheMode == PersistentCache) { + std::cerr << "FileSource::FileSource: Persistent cache mode used for \"" << fileOrUrl.toStdString() << "\"" << std::endl; + exit(1); + } + #ifdef DEBUG_FILE_SOURCE std::cerr << "FileSource::FileSource(" << fileOrUrl.toStdString() << ", " << cacheMode << ")" << std::endl; #endif @@ -128,6 +134,12 @@ m_reporter(reporter), m_refCounted(false) { + + if (cacheMode == PersistentCache) { + std::cerr << "FileSource::FileSource: Persistent cache mode used for \"" << url.toString().toStdString() << "\"" << std::endl; + exit(1); + } + #ifdef DEBUG_FILE_SOURCE std::cerr << "FileSource::FileSource(" << url.toString().toStdString() << ") [as url]" << std::endl; #endif diff -r c9b055f84326 -r 70b333085952 rdf/PluginRDFDescription.cpp --- a/rdf/PluginRDFDescription.cpp Mon Oct 27 18:15:20 2008 +0000 +++ b/rdf/PluginRDFDescription.cpp Mon Oct 27 20:29:55 2008 +0000 @@ -19,6 +19,7 @@ #include "SimpleSPARQLQuery.h" #include "data/fileio/FileSource.h" +#include "data/fileio/CachedFile.h" #include "base/Profiler.h" @@ -29,7 +30,7 @@ using std::endl; PluginRDFDescription::PluginRDFDescription(QString pluginId) : - m_source(0), +//!!! m_source(0), m_pluginId(pluginId), m_haveDescription(false) { @@ -50,7 +51,7 @@ PluginRDFDescription::~PluginRDFDescription() { - delete m_source; +//!!! delete m_source; } bool @@ -168,6 +169,13 @@ //!!! 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()) { @@ -177,6 +185,7 @@ } m_source->waitForData(); local = QUrl::fromLocalFile(m_source->getLocalFilename()).toString(); +*/ } if (!indexMetadata(local, label)) success = false; diff -r c9b055f84326 -r 70b333085952 rdf/PluginRDFDescription.h --- a/rdf/PluginRDFDescription.h Mon Oct 27 18:15:20 2008 +0000 +++ b/rdf/PluginRDFDescription.h Mon Oct 27 20:29:55 2008 +0000 @@ -20,7 +20,7 @@ #include #include -class FileSource; +//!!!class FileSource; class PluginRDFDescription { @@ -56,7 +56,7 @@ typedef std::map OutputDispositionMap; typedef std::map OutputStringMap; - FileSource *m_source; +//!!! FileSource *m_source; QString m_pluginId; bool m_haveDescription; QString m_pluginName; diff -r c9b055f84326 -r 70b333085952 transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Mon Oct 27 18:15:20 2008 +0000 +++ b/transform/TransformFactory.cpp Mon Oct 27 20:29:55 2008 +0000 @@ -561,7 +561,12 @@ if (m_transforms.find(tid) != m_transforms.end()) { std::cerr << "TransformFactory::populateUninstalledTransforms: " - << tid.toStdString() << " is installed, skipping" << std::endl; + << tid.toStdString() << " is installed; adding info url if appropriate, skipping rest" << std::endl; + if (infoUrl != "") { + if (m_transforms[tid].infoUrl == "") { + m_transforms[tid].infoUrl = infoUrl; + } + } continue; } @@ -611,14 +616,6 @@ td.configurable = false; m_uninstalledTransforms[tid] = td; - - if (td.infoUrl != "") { - if (m_transforms.find(tid) != m_transforms.end()) { - if (m_transforms[tid].infoUrl == "") { - m_transforms[tid].infoUrl = td.infoUrl; - } - } - } } }