remove broken overkill plugin cache

This commit is contained in:
Patrick von Reth 2014-07-16 14:58:39 +02:00
parent c041965223
commit 5cc9959bb2
2 changed files with 5 additions and 61 deletions

View File

@ -29,7 +29,7 @@
#include <QDebug>
#include <QMetaEnum>
#include <QApplication>
#include <QSystemSemaphore>
#include <QTime>
using namespace Snore;
@ -120,7 +120,6 @@ void PluginContainer::updatePluginCache()
}
list.clear();
}
cache().remove("");
QList<PluginContainer*> plugins;
@ -150,58 +149,16 @@ void PluginContainer::updatePluginCache()
snoreDebug( SNORE_DEBUG ) << "added" << info->name() << "to cache";
}
}
cache().setValue("version",Version::revision());
cache().setValue("buildtime",Version::buildTime());
cache().setValue("pluginPath",pluginDir().absolutePath());
cache().beginWriteArray("plugins");
for(int i=0;i< plugins.size();++i)
{
cache().setArrayIndex(i);
cache().setValue("fileName",plugins[i]->file());
cache().setValue("name", plugins[i]->name());
cache().setValue("type",(int)plugins[i]->type());
}
cache().endArray();
cache().sync();
}
void PluginContainer::loadPluginCache()
{
int size = cache().beginReadArray("plugins");
for(int i=0;i<size;++i)
{
cache().setArrayIndex(i);
SnorePlugin::PluginTypes type = (SnorePlugin::PluginTypes)cache().value("type").toInt();
QString fileName = cache().value("fileName").toString();
if(QFile(pluginDir().absoluteFilePath(fileName)).exists())
{
PluginContainer *info = new PluginContainer(fileName, cache().value("name").toString(), type);
s_pluginCache[type].insert(info->name(), info);
}
else
{
snoreDebug( SNORE_WARNING ) << "Cache Corrupted" << fileName << cache().value("name").toString() << type;
cache().endArray();
updatePluginCache();
return;
}
}
cache().endArray();
}
const QHash<QString, PluginContainer *> PluginContainer::pluginCache(SnorePlugin::PluginTypes type)
{
if(s_pluginCache.isEmpty())
{
if(cache().value("version").toString() != Version::revision() || qgetenv("LIBSNORE_FORCE_CHACHE_UPDATE").toInt() == 1)
{
updatePluginCache();
}
else
{
loadPluginCache();
}
QTime time;
time.start();
updatePluginCache();
snoreDebug( SNORE_DEBUG ) << "Plugins loaded in:" << time.elapsed();
}
QHash<QString, PluginContainer *> out;

View File

@ -59,7 +59,6 @@ private:
static QHash<SnorePlugin::PluginTypes, PluginContaienrHash > s_pluginCache;
void static updatePluginCache();
void static loadPluginCache();
static const QDir &pluginDir();
static inline const QStringList pluginExtentions()
{
@ -96,18 +95,6 @@ private:
return out;
}
static inline QSettings &cache()
{
static QSettings *_cache = NULL;
if(_cache == NULL)
{
_cache = new QSettings("SnoreNotify","libsnore");
snoreDebug( SNORE_DEBUG ) << _cache->fileName();
_cache->beginGroup( SnoreCorePrivate::computeHash(pluginDir().absolutePath().toLatin1()));
}
return *_cache;
}
QString m_pluginFile;
QString m_pluginName;
SnorePlugin::PluginTypes m_pluginType;