|
|
@ -540,32 +540,25 @@ QString SearchPluginManager::pluginPath(const QString &name) |
|
|
|
return QString("%1/%2.py").arg(pluginsLocation(), name); |
|
|
|
return QString("%1/%2.py").arg(pluginsLocation(), name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PluginVersion SearchPluginManager::getPluginVersion(QString filePath) |
|
|
|
PluginVersion SearchPluginManager::getPluginVersion(const QString &filePath) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QFile plugin(filePath); |
|
|
|
QFile pluginFile(filePath); |
|
|
|
if (!plugin.exists()) { |
|
|
|
if (!pluginFile.open(QIODevice::ReadOnly | QIODevice::Text)) |
|
|
|
qDebug("%s plugin does not exist, returning 0.0", qUtf8Printable(filePath)); |
|
|
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!plugin.open(QIODevice::ReadOnly | QIODevice::Text)) |
|
|
|
|
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
|
|
|
|
|
|
|
|
const PluginVersion invalidVersion; |
|
|
|
while (!pluginFile.atEnd()) { |
|
|
|
|
|
|
|
const QString line = QString(pluginFile.readLine()).remove(' '); |
|
|
|
PluginVersion version; |
|
|
|
|
|
|
|
while (!plugin.atEnd()) { |
|
|
|
|
|
|
|
const QString line = QString(plugin.readLine()).remove(' '); |
|
|
|
|
|
|
|
if (!line.startsWith("#VERSION:", Qt::CaseInsensitive)) continue; |
|
|
|
if (!line.startsWith("#VERSION:", Qt::CaseInsensitive)) continue; |
|
|
|
|
|
|
|
|
|
|
|
const QString versionStr = line.mid(9); |
|
|
|
const QString versionStr = line.mid(9); |
|
|
|
version = PluginVersion::tryParse(versionStr, invalidVersion); |
|
|
|
const PluginVersion version = PluginVersion::tryParse(versionStr, {}); |
|
|
|
if (version == invalidVersion) { |
|
|
|
if (version.isValid()) |
|
|
|
LogMsg(tr("Search plugin '%1' contains invalid version string ('%2')") |
|
|
|
return version; |
|
|
|
.arg(Utils::Fs::fileName(filePath), line), Log::MsgType::WARNING); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogMsg(tr("Search plugin '%1' contains invalid version string ('%2')") |
|
|
|
|
|
|
|
.arg(Utils::Fs::fileName(filePath), versionStr), Log::MsgType::WARNING); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return version; |
|
|
|
|
|
|
|
|
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|