summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-03-17 10:21:00 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-03-17 10:21:00 +0100
commit178a068ad06e8c08a3b769fe0d5c7913ef1b3534 (patch)
tree45dcac4cbc9ff6e65cf4f7ac784732a2c85ba9bf
parent9b798ef4e60425110dbc6f6b67cb931d50646c67 (diff)
downloadsink-178a068ad06e8c08a3b769fe0d5c7913ef1b3534.tar.gz
sink-178a068ad06e8c08a3b769fe0d5c7913ef1b3534.zip
Try starting the synchronizer with an absolute path, and fallback to
PATH Otherwise we don't find the binary in a MacOS bundle.
-rw-r--r--common/resourceaccess.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp
index 201c023..2846b23 100644
--- a/common/resourceaccess.cpp
+++ b/common/resourceaccess.cpp
@@ -215,16 +215,27 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket()
215 return KAsync::error(); 215 return KAsync::error();
216 } 216 }
217 args << resourceInstanceIdentifier << resourceName; 217 args << resourceInstanceIdentifier << resourceName;
218
219 //Prefer a binary next to this binary, otherwise fall-back to PATH. Necessary for MacOS bundles because the bundle is not in the PATH.
220 const QString synchronizerBinaryName = "sink_synchronizer";
221 QString synchronizerBinary = [&]() {
222 const auto path = QCoreApplication::applicationDirPath() + QDir::separator() + synchronizerBinaryName;
223 if (QFileInfo{path}.isExecutable()) {
224 return path;
225 } else {
226 return synchronizerBinaryName;
227 }
228 }();
218 qint64 pid = 0; 229 qint64 pid = 0;
219 if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { 230 if (QProcess::startDetached(synchronizerBinary, args, QDir::homePath(), &pid)) {
220 SinkTrace() << "Started resource " << pid; 231 SinkTrace() << "Started resource " << pid;
221 return tryToConnect() 232 return tryToConnect()
222 .onError([this, args](const KAsync::Error &error) { 233 .onError([this, args](const KAsync::Error &error) {
223 SinkWarning() << "Failed to connect to started resource: sink_synchronizer " << args; 234 SinkWarning() << "Failed to connect to started resource: sink_synchronizer " << args;
224 }); 235 });
225 } else { 236 } else {
226 SinkWarning() << "Failed to start resource"; 237 SinkError() << "Failed to start resource";
227 return KAsync::error(-1, "Failed to start resource"); 238 return KAsync::error(-1, "Failed to start resource.");
228 } 239 }
229 } else { 240 } else {
230 SinkTrace() << "Connected to resource, without having to start it."; 241 SinkTrace() << "Connected to resource, without having to start it.";