summaryrefslogtreecommitdiffstats
path: root/src/gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui.cpp')
-rw-r--r--src/gui.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/gui.cpp b/src/gui.cpp
index 02925ad..67f961c 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -13,6 +13,8 @@
#include <QJsonArray>
#include <QCloseEvent>
+#include <signal.h>
+
static QString STATE_COPYING("COPYING"); // Still busy copying original file, new chunks are only accepted in already copied range
static QString STATE_WAITING_FOR_UPLOAD_DONE("WAITING_FOR_UPLOAD_DONE"); // Copying done, just waiting for new chunks until client signals that it's done
static QString STATE_WAITING_FOR_COPYING_DONE("WAITING_FOR_COPYING_DONE"); // Copying not done, but dnbd3-fuse already told us it's done, wait for copying
@@ -21,16 +23,17 @@ static QString STATE_PROCESSING("PROCESSING"); // Hashing, renaming, creating DB
static QString STATE_ERROR("ERROR");
static QString STATE_COMPLETELY_DONE("COMPLETELY_DONE");
-Gui::Gui(const char *urlbase, const char *uuid, QWidget *parent)
+Gui::Gui(const QString &urlbase, const QString &uuid, int dnbd3pid, QWidget *parent)
: QDialog(parent)
, _nam(new QNetworkAccessManager(this))
- , _urlStatus(QString(urlbase).append("status/").append(uuid))
- , _urlAbort(QString(urlbase).append("abort/").append(uuid))
- , _urlFinish(QString(urlbase).append("finish/").append(uuid))
+ , _urlStatus(urlbase + QLatin1String("status/") + uuid)
+ , _urlAbort(urlbase + QLatin1String("abort/") + uuid)
+ , _urlFinish(urlbase + QLatin1String("finish/") + uuid)
, _denyInteraction(false)
, _allowClose(false)
, _tmrStatus(new QTimer(this))
, _status(nullptr)
+ , _dnbd3pid(dnbd3pid)
{
_nam->setAutoDeleteReplies(true);
_nam->setTransferTimeout(5000);
@@ -162,14 +165,18 @@ void Gui::pushedCancel(bool)
}
if (_denyInteraction)
return;
+ if (_remoteState == STATE_COMPLETELY_DONE) {
+ _btnAbort->setEnabled(false);
+ return;
+ }
if (_remoteState != STATE_ERROR) {
int ret = QMessageBox::question(this, tr("Bestätigung"), tr("Wollen Sie diesen Bearbeitungsvorgang wirklich abbrechen?"));
if (ret == QMessageBox::No)
return;
}
- if (_remoteState == STATE_COMPLETELY_DONE) {
- _btnAbort->setEnabled(false);
- return;
+ if (_dnbd3pid != 0 && _dnbd3pid != -1) {
+ // SIGQUIT tells dnbd3-fuse to stop uploading
+ ::kill(_dnbd3pid, SIGQUIT);
}
_denyInteraction = true;
QNetworkReply *reply = _nam->post(QNetworkRequest(_urlAbort), QByteArray());