svcore
1.9
|
#include <CachedFile.h>
Public Member Functions | |
CachedFile (QString fileOrUrl, ProgressReporter *reporter=0, QString preferredContentType="") | |
CachedFile (QUrl url, ProgressReporter *reporter=0, QString preferredContentType="") | |
virtual | ~CachedFile () |
bool | isOK () const |
QString | getLocalFilename () const |
Protected Types | |
typedef std::map< QString, QString > | OriginLocalFilenameMap |
Protected Member Functions | |
void | checkFile () |
bool | retrieve () |
QDateTime | getLastRetrieval () |
void | updateLastRetrieval (bool successful) |
Static Protected Member Functions | |
static QString | getCacheDirectory () |
static QString | getLocalFilenameFor (QUrl url) |
Protected Attributes | |
QString | m_origin |
QString | m_localFilename |
QString | m_preferredContentType |
ProgressReporter * | m_reporter |
bool | m_ok |
Static Protected Attributes | |
static OriginLocalFilenameMap | m_knownGoodCaches |
Definition at line 26 of file CachedFile.h.
typedef std::map<QString, QString> CachedFile::OriginLocalFilenameMap [protected] |
Definition at line 58 of file CachedFile.h.
CachedFile::CachedFile | ( | QString | fileOrUrl, |
ProgressReporter * | reporter = 0 , |
||
QString | preferredContentType = "" |
||
) |
Definition at line 71 of file CachedFile.cpp.
References checkFile(), and SVDEBUG.
CachedFile::CachedFile | ( | QUrl | url, |
ProgressReporter * | reporter = 0 , |
||
QString | preferredContentType = "" |
||
) |
Definition at line 86 of file CachedFile.cpp.
References checkFile(), and SVDEBUG.
CachedFile::~CachedFile | ( | ) | [virtual] |
Definition at line 101 of file CachedFile.cpp.
bool CachedFile::isOK | ( | ) | const |
Definition at line 106 of file CachedFile.cpp.
References m_ok.
Referenced by PluginRDFIndexer::indexConfiguredURLs(), and PluginRDFIndexer::pullURL().
QString CachedFile::getLocalFilename | ( | ) | const |
Definition at line 112 of file CachedFile.cpp.
References m_localFilename.
Referenced by PluginRDFIndexer::indexConfiguredURLs(), and PluginRDFIndexer::pullURL().
void CachedFile::checkFile | ( | ) | [protected] |
!! n.b. obvious race condition here if different CachedFile
!!
!! but we do want an additional last-attempted
Definition at line 118 of file CachedFile.cpp.
References getLastRetrieval(), getLocalFilenameFor(), m_knownGoodCaches, m_localFilename, m_ok, m_origin, retrieve(), SVDEBUG, and updateLastRetrieval().
Referenced by CachedFile().
bool CachedFile::retrieve | ( | ) | [protected] |
!! need to work by retrieving the file to another name, and !! then "atomically" moving it to its proper place (I'm not !! sure we can do an atomic move to replace an existing file !! using Qt classes, but a plain delete then copy is probably !! good enough)
!! This is not ideal, could leave us with nothing (old file !! removed, new file not able to be copied in because e.g. no !! disk space left)
Definition at line 183 of file CachedFile.cpp.
References FileSource::getLocalFilename(), FileSource::isAvailable(), FileSource::isOK(), m_localFilename, m_origin, m_preferredContentType, m_reporter, SVDEBUG, and FileSource::waitForData().
Referenced by checkFile().
QDateTime CachedFile::getLastRetrieval | ( | ) | [protected] |
Definition at line 235 of file CachedFile.cpp.
References m_localFilename.
Referenced by checkFile().
void CachedFile::updateLastRetrieval | ( | bool | successful | ) | [protected] |
!! note !successful does not mean "we failed to update the !! file" (and so it remains the same as before); it means "the !! file is not there at all"
Definition at line 250 of file CachedFile.cpp.
References m_localFilename.
Referenced by checkFile().
QString CachedFile::getCacheDirectory | ( | ) | [static, protected] |
Definition at line 54 of file CachedFile.cpp.
References TempDirectory::getContainingPath(), and TempDirectory::getInstance().
Referenced by getLocalFilenameFor().
QString CachedFile::getLocalFilenameFor | ( | QUrl | url | ) | [static, protected] |
Definition at line 39 of file CachedFile.cpp.
References getCacheDirectory().
Referenced by checkFile().
QString CachedFile::m_origin [protected] |
Definition at line 43 of file CachedFile.h.
Referenced by checkFile(), and retrieve().
QString CachedFile::m_localFilename [protected] |
Definition at line 44 of file CachedFile.h.
Referenced by checkFile(), getLastRetrieval(), getLocalFilename(), retrieve(), and updateLastRetrieval().
QString CachedFile::m_preferredContentType [protected] |
Definition at line 45 of file CachedFile.h.
Referenced by retrieve().
ProgressReporter* CachedFile::m_reporter [protected] |
Definition at line 46 of file CachedFile.h.
Referenced by retrieve().
bool CachedFile::m_ok [protected] |
Definition at line 47 of file CachedFile.h.
Referenced by checkFile(), and isOK().
CachedFile::OriginLocalFilenameMap CachedFile::m_knownGoodCaches [static, protected] |
Definition at line 59 of file CachedFile.h.
Referenced by checkFile().