Improve desktop file related messages

This commit is contained in:
TheAssassin
2018-06-01 14:57:14 +02:00
parent 8f59b3ef4a
commit 72e20ec6fc
2 changed files with 15 additions and 2 deletions

View File

@@ -101,11 +101,23 @@ namespace linuxdeploy {
}
bool DesktopFile::addDefaultKeys(const std::string& executableFileName) {
ldLog() << "Adding default values to desktop file:" << path() << std::endl;
auto rv = true;
auto setDefault = [&rv, this](const std::string& section, const std::string& key, const std::string& value) {
if (setEntry(section, key, value)) {
if (entryExists(section, key)) {
std::string currentValue;
if (!getEntry(section, key, currentValue))
ldLog() << LD_ERROR << "This should never happen" << std::endl;
ldLog() << LD_WARNING << "Key exists, not modified:" << key << "(current value:" << currentValue << LD_NO_SPACE << ")" << std::endl;
rv = false;
} else {
if (setEntry(section, key, value)) {
// *should* be unreachable
rv = false;
}
}
};

View File

@@ -163,6 +163,7 @@ int main(int argc, char** argv) {
}
ldLog() << std::endl << "-- Creating desktop file --" << std::endl;
ldLog() << LD_WARNING << "Please beware the created desktop file is of low quality and should be edited or replaced before using it for production releases!" << std::endl;
auto executableName = bf::path(executablePaths.Get().front()).filename().string();
@@ -176,7 +177,7 @@ int main(int argc, char** argv) {
desktopfile::DesktopFile desktopFile(desktopFilePath);
if (!desktopFile.addDefaultKeys(executableName)) {
ldLog() << LD_WARNING << "Tried to overwrite existing entries in desktop file" << std::endl;
ldLog() << LD_WARNING << "Tried to overwrite existing entries in desktop file:" << desktopFilePath << std::endl;
}
if (!desktopFile.save()) {