Commit c83c377f authored by Dan Leinir Turthra Jensen's avatar Dan Leinir Turthra Jensen 🌈

Add a RemoveDeadEntries option for knsrc files

If you set RemoveDeadEntries=true, entries whose installed files
have all been deleted without going through KNewStuff will be removed
from the cache. The removal will happen if, and only if, all listed
files were removed, which means that if, for example, an entry was
installed from archive, which was decompressed to yield multiple
installed files, if even one of those files remains, the entry will
remain marked as installed.

This is to help work around people deleting files from underneath
KNewStuff, which turns out to happen a lot with e.g. wallpapers and icons.

CCBUG:417985

Only CCBUGing this one, as it is an imcomplete fix for the issue,
and requires intervention in the icons.knsrc file for the fix to
be applied to the issue mentioned in that bug.
parent 8897e492
......@@ -182,7 +182,15 @@ bool Engine::init(const QString &configfile)
qCDebug(KNEWSTUFFCORE) << "Cache is" << m_cache << "for" << configFileName;
connect(this, &Engine::signalEntryChanged, m_cache.data(), &Cache::registerChangedEntry);
m_cache->readRegistry();
// Cache cleanup option, to help work around people deleting files from underneath KNewStuff (this
// happens a lot with e.g. wallpapers and icons)
bool shouldRemoveDeletedEntries{false};
if (m_installation->uncompressionSetting() == Installation::UseKPackageUncompression) {
shouldRemoveDeletedEntries = true;
}
shouldRemoveDeletedEntries = group.readEntry("RemoveDeadEntries", shouldRemoveDeletedEntries);
if (shouldRemoveDeletedEntries) {
m_cache->removeDeletedEntries();
}
......
......@@ -73,6 +73,13 @@ class DownloadDialogPrivate;
* This is what QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + name will return.</li>
* </ol>
*
* \subsection Remove Dead Entries
*
* If you set <em>RemoveDeadEntries=true</em>, entries whose installed files have all been deleted without going through
* KNewStuff will be removed from the cache. The removal will happen if, and only if, all listed files were removed, which
* means that if, for example, an entry was installed from archive, which was decompressed to yield multiple installed files,
* if even one of those files remains, the entry will remain marked as installed.
*
* \subsection KPackage Support
*
* To make use of the KPackage option described above, in addition to the Uncompress setting above, you should also specify
......@@ -91,6 +98,8 @@ class DownloadDialogPrivate;
KPackageType=Plasma/Theme
* </pre>
*
* \note Using KPackage support will automatically set the removal of dead entries option to true. You can override this if you
* want to, by explicitly adding <em>RemoveDeadEntries=false</em> to your knsrc file
* @since 4.4
*/
class KNEWSTUFF_EXPORT DownloadDialog : public QDialog
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment