|
|
@ -369,67 +369,44 @@ void SearchPluginManager::pluginDownloadFailed(const QString &url, const QString |
|
|
|
// Update nova.py search plugin if necessary
|
|
|
|
// Update nova.py search plugin if necessary
|
|
|
|
void SearchPluginManager::updateNova() |
|
|
|
void SearchPluginManager::updateNova() |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug("Updating nova"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create nova directory if necessary
|
|
|
|
// create nova directory if necessary
|
|
|
|
QDir searchDir(engineLocation()); |
|
|
|
const QDir searchDir(engineLocation()); |
|
|
|
QString novaFolder = Utils::ForeignApps::pythonInfo().version.majorNumber() >= 3 ? "searchengine/nova3" : "searchengine/nova"; |
|
|
|
const QString novaFolder = Utils::ForeignApps::pythonInfo().version.majorNumber() >= 3 |
|
|
|
|
|
|
|
? "searchengine/nova3" : "searchengine/nova"; |
|
|
|
|
|
|
|
|
|
|
|
QFile packageFile(searchDir.absoluteFilePath("__init__.py")); |
|
|
|
QFile packageFile(searchDir.absoluteFilePath("__init__.py")); |
|
|
|
packageFile.open(QIODevice::WriteOnly | QIODevice::Text); |
|
|
|
packageFile.open(QIODevice::WriteOnly); |
|
|
|
packageFile.close(); |
|
|
|
packageFile.close(); |
|
|
|
if (!searchDir.exists("engines")) |
|
|
|
|
|
|
|
searchDir.mkdir("engines"); |
|
|
|
searchDir.mkdir("engines"); |
|
|
|
Utils::Fs::removeDirRecursive(searchDir.absoluteFilePath("__pycache__")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFile packageFile2(searchDir.absolutePath() + "/engines/__init__.py"); |
|
|
|
QFile packageFile2(searchDir.absolutePath() + "/engines/__init__.py"); |
|
|
|
packageFile2.open(QIODevice::WriteOnly | QIODevice::Text); |
|
|
|
packageFile2.open(QIODevice::WriteOnly); |
|
|
|
packageFile2.close(); |
|
|
|
packageFile2.close(); |
|
|
|
|
|
|
|
|
|
|
|
// Copy search plugin files (if necessary)
|
|
|
|
// Copy search plugin files (if necessary)
|
|
|
|
QString filePath = searchDir.absoluteFilePath("nova2.py"); |
|
|
|
const auto updateFile = [&novaFolder](const QString &filename, const bool compareVersion) |
|
|
|
if (getPluginVersion(":/" + novaFolder + "/nova2.py") > getPluginVersion(filePath)) { |
|
|
|
{ |
|
|
|
removePythonScript(filePath); |
|
|
|
const QString filePathBundled = ":/" + novaFolder + '/' + filename; |
|
|
|
QFile::copy(":/" + novaFolder + "/nova2.py", filePath); |
|
|
|
const QString filePathDisk = QDir(engineLocation()).absoluteFilePath(filename); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filePath = searchDir.absoluteFilePath("nova2dl.py"); |
|
|
|
|
|
|
|
if (getPluginVersion(":/" + novaFolder + "/nova2dl.py") > getPluginVersion(filePath)) { |
|
|
|
|
|
|
|
removePythonScript(filePath); |
|
|
|
|
|
|
|
QFile::copy(":/" + novaFolder + "/nova2dl.py", filePath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filePath = searchDir.absoluteFilePath("fix_encoding.py"); |
|
|
|
|
|
|
|
QFile::copy(":/" + novaFolder + "/fix_encoding.py", filePath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filePath = searchDir.absoluteFilePath("novaprinter.py"); |
|
|
|
|
|
|
|
if (getPluginVersion(":/" + novaFolder + "/novaprinter.py") > getPluginVersion(filePath)) { |
|
|
|
|
|
|
|
removePythonScript(filePath); |
|
|
|
|
|
|
|
QFile::copy(":/" + novaFolder + "/novaprinter.py", filePath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filePath = searchDir.absoluteFilePath("helpers.py"); |
|
|
|
if (compareVersion && (getPluginVersion(filePathBundled) <= getPluginVersion(filePathDisk))) |
|
|
|
if (getPluginVersion(":/" + novaFolder + "/helpers.py") > getPluginVersion(filePath)) { |
|
|
|
return; |
|
|
|
removePythonScript(filePath); |
|
|
|
|
|
|
|
QFile::copy(":/" + novaFolder + "/helpers.py", filePath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filePath = searchDir.absoluteFilePath("socks.py"); |
|
|
|
Utils::Fs::forceRemove(filePathDisk); |
|
|
|
removePythonScript(filePath); |
|
|
|
QFile::copy(filePathBundled, filePathDisk); |
|
|
|
QFile::copy(":/" + novaFolder + "/socks.py", filePath); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (novaFolder.endsWith("nova")) { |
|
|
|
updateFile("helpers.py", true); |
|
|
|
filePath = searchDir.absoluteFilePath("fix_encoding.py"); |
|
|
|
updateFile("nova2.py", true); |
|
|
|
removePythonScript(filePath); |
|
|
|
updateFile("nova2dl.py", true); |
|
|
|
QFile::copy(":/" + novaFolder + "/fix_encoding.py", filePath); |
|
|
|
updateFile("novaprinter.py", true); |
|
|
|
} |
|
|
|
updateFile("socks.py", false); |
|
|
|
else if (novaFolder.endsWith("nova3")) { |
|
|
|
|
|
|
|
filePath = searchDir.absoluteFilePath("sgmllib3.py"); |
|
|
|
|
|
|
|
removePythonScript(filePath); |
|
|
|
|
|
|
|
QFile::copy(":/" + novaFolder + "/sgmllib3.py", filePath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDir destDir(pluginsLocation()); |
|
|
|
if (Utils::ForeignApps::pythonInfo().version.majorNumber() >= 3) |
|
|
|
Utils::Fs::removeDirRecursive(destDir.absoluteFilePath("__pycache__")); |
|
|
|
updateFile("sgmllib3.py", false); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
updateFile("fix_encoding.py", false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SearchPluginManager::update() |
|
|
|
void SearchPluginManager::update() |
|
|
|