From c12ae58868d9404d78558857a159a7557d245207 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 24 Jul 2010 10:41:44 +0000 Subject: [PATCH] Stop altering search engine files permissions --- src/searchengine.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/searchengine.cpp b/src/searchengine.cpp index e579617bd..3ae170748 100644 --- a/src/searchengine.cpp +++ b/src/searchengine.cpp @@ -472,64 +472,61 @@ void SearchEngine::updateNova() { qDebug("Updating nova"); // create search_engine directory if necessary QDir search_dir(misc::searchEngineLocation()); - QFile package_file(search_dir.path()+QDir::separator()+"__init__.py"); + QFile package_file(search_dir.absoluteFilePath("__init__.py")); package_file.open(QIODevice::WriteOnly | QIODevice::Text); package_file.close(); if(!search_dir.exists("engines")){ search_dir.mkdir("engines"); } - QFile package_file2(search_dir.path()+QDir::separator()+"engines"+QDir::separator()+"__init__.py"); + QFile package_file2(search_dir.absolutePath().replace("\\", "/")+"/engines/__init__.py"); package_file2.open(QIODevice::WriteOnly | QIODevice::Text); package_file2.close(); // Copy search plugin files (if necessary) - QString filePath = misc::searchEngineLocation()+QDir::separator()+"nova2.py"; + QString filePath = search_dir.absoluteFilePath("nova2.py"); if(getPluginVersion(":/search_engine/nova2.py") > getPluginVersion(filePath)) { if(QFile::exists(filePath)) QFile::remove(filePath); QFile::copy(":/search_engine/nova2.py", filePath); } - // Set permissions - QFile::Permissions perm=QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser | QFile::ReadGroup | QFile::ReadGroup; - QFile(misc::searchEngineLocation()+QDir::separator()+"nova2.py").setPermissions(perm); - filePath = misc::searchEngineLocation()+QDir::separator()+"nova2dl.py"; + filePath = search_dir.absoluteFilePath("nova2dl.py"); if(getPluginVersion(":/search_engine/nova2dl.py") > getPluginVersion(filePath)) { if(QFile::exists(filePath)){ QFile::remove(filePath); } QFile::copy(":/search_engine/nova2dl.py", filePath); } - QFile(misc::searchEngineLocation()+QDir::separator()+"nova2dl.py").setPermissions(perm); - filePath = misc::searchEngineLocation()+QDir::separator()+"novaprinter.py"; + + filePath = search_dir.absoluteFilePath("novaprinter.py"); if(getPluginVersion(":/search_engine/novaprinter.py") > getPluginVersion(filePath)) { if(QFile::exists(filePath)){ QFile::remove(filePath); } QFile::copy(":/search_engine/novaprinter.py", filePath); } - QFile(misc::searchEngineLocation()+QDir::separator()+"novaprinter.py").setPermissions(perm); - filePath = misc::searchEngineLocation()+QDir::separator()+"helpers.py"; + + filePath = search_dir.absoluteFilePath("helpers.py"); if(getPluginVersion(":/search_engine/helpers.py") > getPluginVersion(filePath)) { if(QFile::exists(filePath)){ QFile::remove(filePath); } QFile::copy(":/search_engine/helpers.py", filePath); } - QFile(misc::searchEngineLocation()+QDir::separator()+"socks.py").setPermissions(perm); - filePath = misc::searchEngineLocation()+QDir::separator()+"socks.py"; + + filePath = search_dir.absoluteFilePath("socks.py"); if(!QFile::exists(filePath)) { QFile::copy(":/search_engine/socks.py", filePath); } - QString destDir = misc::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator(); + QDir destDir(QDir(misc::searchEngineLocation()).absoluteFilePath("engines")); QDir shipped_subDir(":/search_engine/engines/"); QStringList files = shipped_subDir.entryList(); foreach(const QString &file, files){ - QString shipped_file = shipped_subDir.path()+"/"+file; + QString shipped_file = shipped_subDir.absoluteFilePath(file); // Copy python classes if(file.endsWith(".py")) { - const QString dest_file = destDir+file; + const QString dest_file = destDir.absoluteFilePath(file); if(getPluginVersion(shipped_file) > getPluginVersion(dest_file) ) { - qDebug("shippped %s is more recent then local plugin, updating", qPrintable(file)); + qDebug("shipped %s is more recent then local plugin, updating...", qPrintable(file)); if(QFile::exists(dest_file)) { qDebug("Removing old %s", qPrintable(dest_file)); QFile::remove(dest_file); @@ -540,8 +537,8 @@ void SearchEngine::updateNova() { } else { // Copy icons if(file.endsWith(".png")) { - if(!QFile::exists(destDir+file)) { - QFile::copy(shipped_file, destDir+file); + if(!QFile::exists(destDir.absoluteFilePath(file))) { + QFile::copy(shipped_file, destDir.absoluteFilePath(file)); } } }