Create the service directory, in case it doesn't exist.

Fixes package installation with non-existing local directories.
This commit is contained in:
Sebastian Kügler 2013-02-18 04:09:50 +01:00
parent bbf7e910ec
commit c662f09a7c

View File

@ -197,7 +197,6 @@ bool PackageJobThread::installPackage(const QString& src, const QString &dest)
archivedPackage = true; archivedPackage = true;
path = tempdir.path() + '/'; path = tempdir.path() + '/';
//kDebug() << "path: " << path;
d->installPath = path; d->installPath = path;
const KArchiveDirectory *source = archive->directory(); const KArchiveDirectory *source = archive->directory();
@ -216,7 +215,7 @@ bool PackageJobThread::installPackage(const QString& src, const QString &dest)
QString metadataPath = path + "metadata.desktop"; QString metadataPath = path + "metadata.desktop";
if (!QFile::exists(metadataPath)) { if (!QFile::exists(metadataPath)) {
//kWarning() << "No metadata file in package" << src << metadataPath; kDebug() << "No metadata file in package" << src << metadataPath;
d->errorMessage = i18n("No metadata file in package: %1", src); d->errorMessage = i18n("No metadata file in package: %1", src);
return false; return false;
} }
@ -234,7 +233,7 @@ bool PackageJobThread::installPackage(const QString& src, const QString &dest)
// bad characters into the paths used for removal. // bad characters into the paths used for removal.
QRegExp validatePluginName("^[\\w-\\.]+$"); // Only allow letters, numbers, underscore and period. QRegExp validatePluginName("^[\\w-\\.]+$"); // Only allow letters, numbers, underscore and period.
if (!validatePluginName.exactMatch(pluginName)) { if (!validatePluginName.exactMatch(pluginName)) {
//kWarning() << "Package plugin name " << pluginName << "contains invalid characters"; //kDebug() << "Package plugin name " << pluginName << "contains invalid characters";
d->errorMessage = i18n("Package plugin name %1 contains invalid characters", pluginName); d->errorMessage = i18n("Package plugin name %1 contains invalid characters", pluginName);
return false; return false;
} }
@ -245,7 +244,6 @@ bool PackageJobThread::installPackage(const QString& src, const QString &dest)
} }
targetName.append(pluginName); targetName.append(pluginName);
//kDebug() << " Target installation path: " << targetName;
if (QFile::exists(targetName)) { if (QFile::exists(targetName)) {
//kWarning() << targetName << "already exists"; //kWarning() << targetName << "already exists";
d->errorMessage = i18n("%1 already exists", targetName); d->errorMessage = i18n("%1 already exists", targetName);
@ -292,10 +290,15 @@ bool PackageJobThread::installPackage(const QString& src, const QString &dest)
const QString serviceName = d->servicePrefix + meta.pluginName() + ".desktop"; const QString serviceName = d->servicePrefix + meta.pluginName() + ".desktop";
QString service = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kde5/services/") + serviceName; QString localServiceDirectory = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kde5/services/");
//kDebug() << "Copying from " << metaPath << " to " << service; if (!QDir().mkpath(localServiceDirectory)) {
kDebug() << "Failed to create ... " << localServiceDirectory;
}
QString service = localServiceDirectory + serviceName;
const bool ok = QFile::copy(metaPath, service); const bool ok = QFile::copy(metaPath, service);
if (ok) { if (ok) {
//kDebug() << "Copying metadata went ok.";
// the icon in the installed file needs to point to the icon in the // the icon in the installed file needs to point to the icon in the
// installation dir! // installation dir!
QString iconPath = targetName + '/' + cg.readEntry("Icon"); QString iconPath = targetName + '/' + cg.readEntry("Icon");
@ -306,7 +309,7 @@ bool PackageJobThread::installPackage(const QString& src, const QString &dest)
cg.writeEntry("Icon", iconPath); cg.writeEntry("Icon", iconPath);
} }
} else { } else {
//kWarning() << "Could not register package as service (this is not necessarily fatal):" << serviceName; kDebug() << "Could not register package as service (this is not necessarily fatal):" << serviceName;
d->errorMessage = i18n("Could not register package as service (this is not necessarily fatal): %1", serviceName); d->errorMessage = i18n("Could not register package as service (this is not necessarily fatal): %1", serviceName);
} }
} }