Skip to content

Commit

Permalink
Reorganize cache and temporary directories under common parents.
Browse files Browse the repository at this point in the history
Previously, various cache and temporary directories were sprinkled all
over ~/.mythtv, aka MYTHCONFDIR.  This change puts them all under
~/.mythtv/cache or ~/.mythtv/tmp, though, there could still be a few
I've missed.  Some of these directories can get quite large and having
them all in more centralized locations makes it easier to track how
much space they use and to not back them up.
  • Loading branch information
gigem committed Mar 12, 2014
1 parent 1da2a0e commit 85b2d6d
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 27 deletions.
4 changes: 2 additions & 2 deletions mythplugins/mythgallery/mythgallery/galleryutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ bool GalleryUtil::Rename(const QString &currDir, const QString &oldName,
// rename the file's thumbnail if it exists
if (QFile::exists(currDir + "/.thumbcache/" + oldName))
{
QDir d(currDir + "/.thumbcache/");
QDir d(currDir + "/cache/gallery-thumbcache/");
d.rename(oldName, newName);
}

Expand Down Expand Up @@ -656,7 +656,7 @@ bool GalleryUtil::RenameDirectory(const QString &currDir, const QString &oldName
// rename the directory's thumbnail if it exists in the parent directory
if (QFile::exists(currDir + "/.thumbcache/" + oldName))
{
QDir d(currDir + "/.thumbcache/");
QDir d(currDir + "/cache/gallery-thumbcache/");
d.rename(oldName, newName);
}

Expand Down
8 changes: 4 additions & 4 deletions mythplugins/mythmusic/mythmusic/cdrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void CDRipperThread::run(void)
}

MusicMetadata *titleTrack = NULL;
QString saveDir = GetConfDir() + "/MythMusic/RipTemp/";
QString saveDir = GetConfDir() + "/tmp/RipTemp/";
QString outfile;

std::auto_ptr<Encoder> encoder;
Expand Down Expand Up @@ -571,10 +571,10 @@ Ripper::Ripper(MythScreenStack *parent, QString device) :

// make sure the directory where we temporarily save the rips is present
QDir dir;
dir.mkpath(GetConfDir() + "/MythMusic/RipTemp/");
dir.mkpath(GetConfDir() + "/tmp/RipTemp/");

// remove any ripped tracks from the temp rip directory
QString command = "rm -f " + GetConfDir() + "/MythMusic/RipTemp/*";
QString command = "rm -f " + GetConfDir() + "/tmp/RipTemp/*";
myth_system(command);

// get last host and directory we ripped to
Expand All @@ -587,7 +587,7 @@ Ripper::Ripper(MythScreenStack *parent, QString device) :
Ripper::~Ripper(void)
{
// remove any ripped tracks from the temp rip directory
QString command = "rm -f " + GetConfDir() + "/MythMusic/RipTemp/*";
QString command = "rm -f " + GetConfDir() + "/tmp/RipTemp/*";
myth_system(command);

if (m_decoder)
Expand Down
8 changes: 1 addition & 7 deletions mythplugins/mythnetvision/mythnetvision/netcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ QString GetThumbnailFilename(QString url, QString title)
if (!dir.exists())
dir.mkdir(fileprefix);

fileprefix += "/MythNetvision";

dir = QDir(fileprefix);
if (!dir.exists())
dir.mkdir(fileprefix);

fileprefix += "/thumbcache";
fileprefix += "/cache/netvision-thumbcache";

dir = QDir(fileprefix);
if (!dir.exists())
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythnetvision/mythnetvision/netsearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void NetSearch::fillGrabberButtonList()

void NetSearch::cleanCacheDir()
{
QString cache = QString("%1/MythNetvision/thumbcache")
QString cache = QString("%1/cache/netvision-thumbcache")
.arg(GetConfDir());
QDir cacheDir(cache);
QStringList thumbs = cacheDir.entryList(QDir::Files);
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythnetvision/mythnetvision/nettree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ NetTree::~NetTree()

void NetTree::cleanCacheDir()
{
QString cache = QString("%1/thumbcache")
QString cache = QString("%1/cache/netvision-thumbcache")
.arg(GetConfDir());
QDir cacheDir(cache);
QStringList thumbs = cacheDir.entryList(QDir::Files);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythdownloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void MythDownloadManager::run(void)
m_manager = new QNetworkAccessManager(this);
m_diskCache = new QNetworkDiskCache(this);
m_proxy = new QNetworkProxy();
m_diskCache->setCacheDirectory(GetConfDir() + "/Cache-" +
m_diskCache->setCacheDirectory(GetConfDir() + "/cache/" +
QCoreApplication::applicationName() + "-" +
gCoreContext->GetHostName());
m_manager->setCache(m_diskCache);
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythmetadata/metadataimagedownload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ QString getDownloadFilename(QString title, QString url)
if (!dir.exists())
dir.mkdir(fileprefix);

fileprefix += "/thumbcache";
fileprefix += "/cache/metadata-thumbcache";

dir = QDir(fileprefix);
if (!dir.exists())
Expand Down Expand Up @@ -515,7 +515,7 @@ QString getLocalStorageGroupPath(VideoArtworkType type, QString host)

void cleanThumbnailCacheDir()
{
QString cache = QString("%1/thumbcache")
QString cache = QString("%1/cache/metadata-thumbcache")
.arg(GetConfDir());
QDir cacheDir(cache);
QStringList thumbs = cacheDir.entryList(QDir::Files);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythmetadata/mythuiimageresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool ImageSearchResultsDialog::Create()

void ImageSearchResultsDialog::cleanCacheDir()
{
QString cache = QString("%1/thumbcache")
QString cache = QString("%1/cache/metadata-thumbcache")
.arg(GetConfDir());
QDir cacheDir(cache);
QStringList thumbs = cacheDir.entryList(QDir::Files);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythmetadata/mythuimetadataresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ bool MetadataResultsDialog::Create()

void MetadataResultsDialog::cleanCacheDir()
{
QString cache = QString("%1/thumbcache")
QString cache = QString("%1/cache/metadata-thumbcache")
.arg(GetConfDir());
QDir cacheDir(cache);
QStringList thumbs = cacheDir.entryList(QDir::Files);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/previewgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ bool PreviewGenerator::SaveOutFile(const QByteArray &data, const QDateTime &dt)
if (m_outFileName.isEmpty())
{
QString remotecachedirname =
QString("%1/remotecache").arg(GetConfDir());
QString("%1/cache/remotecache").arg(GetConfDir());
QDir remotecachedir(remotecachedirname);

if (!remotecachedir.exists())
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/previewgeneratorqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ QString PreviewGeneratorQueue::GeneratePreviewImage(

if (streaming)
{
ret_file = QString("%1/remotecache/%2")
ret_file = QString("%1/cache/remotecache/%2")
.arg(GetConfDir()).arg(filename.section('/', -1));

QFileInfo finfo(ret_file);
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythui/mythuihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ bool MythUIHelper::IsImageInCache(const QString &url)

QString MythUIHelper::GetThemeCacheDir(void)
{
QString cachedirname = GetConfDir() + "/themecache/";
QString cachedirname = GetConfDir() + "/cache/themecache/";

QString tmpcachedir = cachedirname +
GetMythDB()->GetSetting("Theme", DEFAULT_UI_THEME) +
Expand All @@ -731,7 +731,7 @@ QString MythUIHelper::GetThemeCacheDir(void)

void MythUIHelper::ClearOldImageCache(void)
{
QString cachedirname = GetConfDir() + "/themecache/";
QString cachedirname = GetConfDir() + "/cache/themecache/";

d->themecachedir = GetThemeCacheDir();

Expand Down Expand Up @@ -795,7 +795,7 @@ void MythUIHelper::ClearOldImageCache(void)

void MythUIHelper::RemoveCacheDir(const QString &dirname)
{
QString cachedirname = GetConfDir() + "/themecache/";
QString cachedirname = GetConfDir() + "/cache/themecache/";

if (!dirname.startsWith(cachedirname))
return;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythtv-setup/importicons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ImportIconsWizard::ImportIconsWizard(MythScreenStack *parent, bool fRefresh,

m_popupStack = GetMythMainWindow()->GetStack("popup stack");

m_tmpDir = QDir(QString("%1/icontmp").arg(GetConfDir()));
m_tmpDir = QDir(QString("%1/tmp/icon").arg(GetConfDir()));

if (!m_tmpDir.exists())
m_tmpDir.mkpath(m_tmpDir.absolutePath());
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/scripts/metadata/Movie/tmdb3.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def main():
print "Unable to find MythTV directory for metadata cache."
sys.exit(1)
confdir = os.path.join(confdir, '.mythtv')
confpath = os.path.join(confdir, 'pytmdb3.cache')
confpath = os.path.join(confdir, 'cache/pytmdb3.cache')
if not os.access(confpath, os.F_OK|os.W_OK|os.R_OK):
print "Unable to access cache file: "+confpath
sys.exit(1)
Expand Down

0 comments on commit 85b2d6d

Please sign in to comment.