From 4167259a6c88392303e28b2c98042a4c60dbcb99 Mon Sep 17 00:00:00 2001 From: Chris Pinkham Date: Fri, 14 Jun 2013 22:38:21 -0700 Subject: [PATCH] Check user themes directory for writability before downloading theme. This patch will check that the user's themes directory (normally ~/.mythtv/themes on a *nix system) is writable when the user enters the Theme Chooser screen and warn the user if it is not writable. Another check happens at theme download time to warn the user if the selected theme can not be downloaded and installed if the themes directory is not writable. Fixes #10634. --- mythtv/programs/mythfrontend/themechooser.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mythtv/programs/mythfrontend/themechooser.cpp b/mythtv/programs/mythfrontend/themechooser.cpp index 8af46c13b79..0b8caaecd3a 100644 --- a/mythtv/programs/mythfrontend/themechooser.cpp +++ b/mythtv/programs/mythfrontend/themechooser.cpp @@ -401,6 +401,16 @@ void ThemeChooser::Init(void) MythUIButtonListItem *current = m_themes->GetItemCurrent(); if (current) itemChanged(current); + + QString testFile = m_userThemeDir + "/.test"; + QFile test(testFile); + if (test.open(QIODevice::WriteOnly)) + test.remove(); + else + { + ShowOkPopup(tr("Error creating test file, %1 themes directory is " + "not writable.").arg(m_userThemeDir)); + } } ThemeInfo *ThemeChooser::loadThemeInfo(QFileInfo &theme) @@ -600,6 +610,17 @@ void ThemeChooser::saveAndReload(MythUIButtonListItem *item) if (!info->GetDownloadURL().isEmpty()) { + QString testFile = m_userThemeDir + "/.test"; + QFile test(testFile); + if (test.open(QIODevice::WriteOnly)) + test.remove(); + else + { + ShowOkPopup(tr("Unable to install theme, %1 themes directory is " + "not writable.").arg(m_userThemeDir)); + return; + } + QString downloadURL = info->GetDownloadURL(); QFileInfo qfile(downloadURL); QString baseName = qfile.fileName();