summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/domain/applicationdomaintype.h3
-rw-r--r--common/resourceaccess.cpp4
-rw-r--r--common/resourcecontrol.cpp7
-rw-r--r--sinksh/state.cpp2
-rw-r--r--sinksh/syntax_modules/sink_sync.cpp4
-rw-r--r--sinksh/syntaxtree.cpp10
-rw-r--r--sinksh/syntaxtree.h2
7 files changed, 21 insertions, 11 deletions
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h
index de2b5c9..dc4cbe1 100644
--- a/common/domain/applicationdomaintype.h
+++ b/common/domain/applicationdomaintype.h
@@ -102,7 +102,8 @@ enum SINK_EXPORT ErrorCode {
102 ConfigurationError, 102 ConfigurationError,
103 TransmissionError, 103 TransmissionError,
104 ConnectionLostError, 104 ConnectionLostError,
105 MissingCredentialsError 105 MissingCredentialsError,
106 ResourceCrashedError
106}; 107};
107 108
108enum SINK_EXPORT SuccessCode { 109enum SINK_EXPORT SuccessCode {
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp
index a3478e6..8b70684 100644
--- a/common/resourceaccess.cpp
+++ b/common/resourceaccess.cpp
@@ -526,6 +526,10 @@ void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error)
526 Sink::Notification n; 526 Sink::Notification n;
527 n.type = Sink::Notification::Status; 527 n.type = Sink::Notification::Status;
528 emit notification(n); 528 emit notification(n);
529 Sink::Notification crashNotification;
530 crashNotification.type = Sink::Notification::Error;
531 crashNotification.code = Sink::ApplicationDomain::ResourceCrashedError;
532 emit notification(crashNotification);
529 d->abortPendingOperations(); 533 d->abortPendingOperations();
530 } else if (error == QLocalSocket::PeerClosedError) { 534 } else if (error == QLocalSocket::PeerClosedError) {
531 SinkLog() << "The resource closed the connection."; 535 SinkLog() << "The resource closed the connection.";
diff --git a/common/resourcecontrol.cpp b/common/resourcecontrol.cpp
index b6a4c0b..a69b7fa 100644
--- a/common/resourcecontrol.cpp
+++ b/common/resourcecontrol.cpp
@@ -101,10 +101,13 @@ KAsync::Job<void> ResourceControl::flush(Flush::FlushType type, const QByteArray
101 SinkTrace() << "Waiting for flush completion notification " << id; 101 SinkTrace() << "Waiting for flush completion notification " << id;
102 notifier->registerHandler([&future, id](const Notification &notification) { 102 notifier->registerHandler([&future, id](const Notification &notification) {
103 SinkTrace() << "Received notification: " << notification.type << notification.id; 103 SinkTrace() << "Received notification: " << notification.type << notification.id;
104 if (notification.id == id) { 104 if (notification.type == Notification::Error && notification.code == ApplicationDomain::ResourceCrashedError) {
105 SinkWarning() << "Error during flush";
106 future.setError(-1, "Error during flush: " + notification.message);
107 } else if (notification.id == id) {
105 SinkTrace() << "FlushComplete"; 108 SinkTrace() << "FlushComplete";
106 if (notification.code) { 109 if (notification.code) {
107 SinkWarning() << "Flush return an error"; 110 SinkWarning() << "Flush returned an error";
108 future.setError(-1, "Flush returned an error: " + notification.message); 111 future.setError(-1, "Flush returned an error: " + notification.message);
109 } else { 112 } else {
110 future.setFinished(); 113 future.setFinished();
diff --git a/sinksh/state.cpp b/sinksh/state.cpp
index 7e04d28..b7e8e5a 100644
--- a/sinksh/state.cpp
+++ b/sinksh/state.cpp
@@ -139,7 +139,7 @@ int State::commandStarted() const
139 139
140void State::commandFinished(int returnCode) const 140void State::commandFinished(int returnCode) const
141{ 141{
142 SinkTrace() << "Command finished"; 142 SinkTrace() << "Command finished. Exit code: " << returnCode;
143 if (!s_hasEventLoop) { 143 if (!s_hasEventLoop) {
144 QCoreApplication::exit(returnCode); 144 QCoreApplication::exit(returnCode);
145 } else { 145 } else {
diff --git a/sinksh/syntax_modules/sink_sync.cpp b/sinksh/syntax_modules/sink_sync.cpp
index 2800af1..8b48785 100644
--- a/sinksh/syntax_modules/sink_sync.cpp
+++ b/sinksh/syntax_modules/sink_sync.cpp
@@ -67,12 +67,14 @@ bool sync(const QStringList &args, State &state)
67 Sink::Store::synchronize(query) 67 Sink::Store::synchronize(query)
68 .then(Sink::ResourceControl::flushMessageQueue(query.getResourceFilter().ids)) 68 .then(Sink::ResourceControl::flushMessageQueue(query.getResourceFilter().ids))
69 .then([state](const KAsync::Error &error) { 69 .then([state](const KAsync::Error &error) {
70 int exitCode = 0;
70 if (error) { 71 if (error) {
71 state.printLine("Synchronization failed!"); 72 state.printLine("Synchronization failed!");
73 exitCode = 1;
72 } else { 74 } else {
73 state.printLine("Synchronization complete!"); 75 state.printLine("Synchronization complete!");
74 } 76 }
75 state.commandFinished(); 77 state.commandFinished(exitCode);
76 }).exec(); 78 }).exec();
77 79
78 return true; 80 return true;
diff --git a/sinksh/syntaxtree.cpp b/sinksh/syntaxtree.cpp
index ee9d6f8..65eb769 100644
--- a/sinksh/syntaxtree.cpp
+++ b/sinksh/syntaxtree.cpp
@@ -57,16 +57,16 @@ Syntax::List SyntaxTree::syntax() const
57 return m_syntax; 57 return m_syntax;
58} 58}
59 59
60bool SyntaxTree::run(const QStringList &commands) 60int SyntaxTree::run(const QStringList &commands)
61{ 61{
62 bool success = false; 62 int returnCode = 0;
63 m_timeElapsed.start(); 63 m_timeElapsed.start();
64 Command command = match(commands); 64 Command command = match(commands);
65 if (command.first) { 65 if (command.first) {
66 if (command.first->lambda) { 66 if (command.first->lambda) {
67 success = command.first->lambda(command.second, m_state); 67 bool success = command.first->lambda(command.second, m_state);
68 if (success && command.first->interactivity == Syntax::EventDriven) { 68 if (success && command.first->interactivity == Syntax::EventDriven) {
69 success = m_state.commandStarted(); 69 returnCode = m_state.commandStarted();
70 } 70 }
71 } else if (command.first->children.isEmpty()) { 71 } else if (command.first->children.isEmpty()) {
72 m_state.printError(QObject::tr("Broken command... sorry :("), "st_broken"); 72 m_state.printError(QObject::tr("Broken command... sorry :("), "st_broken");
@@ -85,7 +85,7 @@ bool SyntaxTree::run(const QStringList &commands)
85 if (m_state.commandTiming()) { 85 if (m_state.commandTiming()) {
86 m_state.printLine(QObject::tr("Time elapsed: %1").arg(m_timeElapsed.elapsed())); 86 m_state.printLine(QObject::tr("Time elapsed: %1").arg(m_timeElapsed.elapsed()));
87 } 87 }
88 return false; 88 return returnCode;
89} 89}
90 90
91SyntaxTree::Command SyntaxTree::match(const QStringList &commandLine) const 91SyntaxTree::Command SyntaxTree::match(const QStringList &commandLine) const
diff --git a/sinksh/syntaxtree.h b/sinksh/syntaxtree.h
index 6624388..8fbbd01 100644
--- a/sinksh/syntaxtree.h
+++ b/sinksh/syntaxtree.h
@@ -63,7 +63,7 @@ public:
63 Command match(const QStringList &commands) const; 63 Command match(const QStringList &commands) const;
64 Syntax::List nearestSyntax(const QStringList &words, const QString &fragment) const; 64 Syntax::List nearestSyntax(const QStringList &words, const QString &fragment) const;
65 State &state(); 65 State &state();
66 bool run(const QStringList &commands); 66 int run(const QStringList &commands);
67 67
68 static QStringList tokenize(const QString &text); 68 static QStringList tokenize(const QString &text);
69 69