mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 22:33:34 -07:00
3_2_x mapping: [search engine] Remove python3 cache during updateNova()
This commit is contained in:
parent
23842a8ec3
commit
aac6a4526c
3 changed files with 27 additions and 2 deletions
|
@ -187,6 +187,27 @@ bool fsutils::forceRemove(const QString& file_path) {
|
||||||
return f.remove();
|
return f.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes directory and its content recursively.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void fsutils::removeDirRecursive(const QString& dirName) {
|
||||||
|
QDir dir(dirName);
|
||||||
|
|
||||||
|
if (!dir.exists()) return;
|
||||||
|
|
||||||
|
Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot |
|
||||||
|
QDir::System |
|
||||||
|
QDir::Hidden |
|
||||||
|
QDir::AllDirs |
|
||||||
|
QDir::Files, QDir::DirsFirst)) {
|
||||||
|
if (info.isDir()) removeDirRecursive(info.absoluteFilePath());
|
||||||
|
else forceRemove(info.absoluteFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
dir.rmdir(dirName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size of a file.
|
* Returns the size of a file.
|
||||||
* If the file is a folder, it will compute its size based on its content.
|
* If the file is a folder, it will compute its size based on its content.
|
||||||
|
|
|
@ -57,6 +57,7 @@ namespace fsutils
|
||||||
bool isValidTorrentFile(const QString& path);
|
bool isValidTorrentFile(const QString& path);
|
||||||
bool smartRemoveEmptyFolderTree(const QString& dir_path);
|
bool smartRemoveEmptyFolderTree(const QString& dir_path);
|
||||||
bool forceRemove(const QString& file_path);
|
bool forceRemove(const QString& file_path);
|
||||||
|
void removeDirRecursive(const QString& dirName);
|
||||||
|
|
||||||
/* Ported from Qt4 to drop dependency on QtGui */
|
/* Ported from Qt4 to drop dependency on QtGui */
|
||||||
QString QDesktopServicesDataLocation();
|
QString QDesktopServicesDataLocation();
|
||||||
|
|
|
@ -335,6 +335,8 @@ void SearchEngine::updateNova() {
|
||||||
if (!search_dir.exists("engines")) {
|
if (!search_dir.exists("engines")) {
|
||||||
search_dir.mkdir("engines");
|
search_dir.mkdir("engines");
|
||||||
}
|
}
|
||||||
|
fsutils::removeDirRecursive(search_dir.absoluteFilePath("__pycache__"));
|
||||||
|
|
||||||
QFile package_file2(search_dir.absolutePath() + "/engines/__init__.py");
|
QFile package_file2(search_dir.absolutePath() + "/engines/__init__.py");
|
||||||
package_file2.open(QIODevice::WriteOnly | QIODevice::Text);
|
package_file2.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
package_file2.close();
|
package_file2.close();
|
||||||
|
@ -372,13 +374,14 @@ void SearchEngine::updateNova() {
|
||||||
removePythonScriptIfExists(filePath);
|
removePythonScriptIfExists(filePath);
|
||||||
QFile::copy(":/"+nova_folder+"/fix_encoding.py", filePath);
|
QFile::copy(":/"+nova_folder+"/fix_encoding.py", filePath);
|
||||||
}
|
}
|
||||||
|
else if (nova_folder == "nova3") {
|
||||||
if (nova_folder == "nova3") {
|
|
||||||
filePath = search_dir.absoluteFilePath("sgmllib3.py");
|
filePath = search_dir.absoluteFilePath("sgmllib3.py");
|
||||||
removePythonScriptIfExists(filePath);
|
removePythonScriptIfExists(filePath);
|
||||||
QFile::copy(":/"+nova_folder+"/sgmllib3.py", filePath);
|
QFile::copy(":/"+nova_folder+"/sgmllib3.py", filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir destDir(QDir(fsutils::searchEngineLocation()).absoluteFilePath("engines"));
|
QDir destDir(QDir(fsutils::searchEngineLocation()).absoluteFilePath("engines"));
|
||||||
|
fsutils::removeDirRecursive(destDir.absoluteFilePath("__pycache__"));
|
||||||
QDir shipped_subDir(":/"+nova_folder+"/engines/");
|
QDir shipped_subDir(":/"+nova_folder+"/engines/");
|
||||||
QStringList files = shipped_subDir.entryList();
|
QStringList files = shipped_subDir.entryList();
|
||||||
foreach (const QString &file, files) {
|
foreach (const QString &file, files) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue