mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-15 18:21:35 +03:00
Long Running Put: Better error reporting
This commit is contained in:
parent
7480d34742
commit
550d6d66d1
7 changed files with 34 additions and 18 deletions
|
@ -462,12 +462,14 @@ void CleanupPollsJob::slotPollFinished()
|
|||
{
|
||||
PollJob *job = qobject_cast<PollJob *>(sender());
|
||||
Q_ASSERT(job);
|
||||
if (!job->_error.isEmpty()) {
|
||||
qDebug() << "There was an error with file " << job->_item._file << job->_error ;
|
||||
if (job->_item._status == SyncFileItem::FatalError) {
|
||||
emit aborted(job->_item._errorString);
|
||||
return;
|
||||
} else if (job->_item._status != SyncFileItem::Success) {
|
||||
qDebug() << "There was an error with file " << job->_item._file << job->_item._errorString;
|
||||
} else {
|
||||
_journal->setFileRecord(SyncJournalFileRecord(job->_item, _localPath + job->_item._file));
|
||||
}
|
||||
|
||||
// Continue with the next entry, or finish
|
||||
start();
|
||||
}
|
||||
|
|
|
@ -271,6 +271,7 @@ public:
|
|||
void start();
|
||||
signals:
|
||||
void finished();
|
||||
void aborted(const QString &error);
|
||||
private slots:
|
||||
void slotPollFinished();
|
||||
};
|
||||
|
|
|
@ -96,28 +96,34 @@ bool PollJob::finished()
|
|||
{
|
||||
QNetworkReply::NetworkError err = reply()->error();
|
||||
if (err != QNetworkReply::NoError) {
|
||||
_item._httpErrorCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
_item._status = classifyError(err, _item._httpErrorCode);
|
||||
_item._errorString = reply()->errorString();
|
||||
if (_item._status == SyncFileItem::FatalError || int(_item._httpErrorCode / 100) == 4) {
|
||||
emit finishedSignal();
|
||||
return true;
|
||||
}
|
||||
start();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
QVariantMap status = QtJson::parse(QString::fromUtf8(reply()->readAll()), ok).toMap();
|
||||
if (!ok || status.isEmpty()) {
|
||||
qDebug() << "Invalid json reply from the poll URL";
|
||||
_item._errorString = tr("Invalid json reply from the poll URL");
|
||||
_item._status = SyncFileItem::NormalError;
|
||||
emit finishedSignal();
|
||||
// FIXME: retry?
|
||||
return true;
|
||||
}
|
||||
|
||||
// the following code only happens after all chunks were uploaded.
|
||||
// the file id should only be empty for new files up- or downloaded
|
||||
QByteArray fid = status["fileid"].toByteArray();
|
||||
if( !fid.isEmpty() ) {
|
||||
if( !_item._fileId.isEmpty() && _item._fileId != fid ) {
|
||||
qDebug() << "WARN: File ID changed!" << _item._fileId << fid;
|
||||
}
|
||||
_item._fileId = fid;
|
||||
if (status["unfinished"].isValid()) {
|
||||
start();
|
||||
return false;
|
||||
}
|
||||
|
||||
_item._errorString = status["error"].toString();
|
||||
_item._status = _item._errorString.isEmpty() ? SyncFileItem::NormalError : SyncFileItem::Success;
|
||||
_item._fileId = status["fileid"].toByteArray();
|
||||
_item._etag = status["etag"].toByteArray();
|
||||
_item._responseTimeStamp = responseTimestamp();
|
||||
|
||||
|
@ -462,8 +468,8 @@ void PropagateUploadFileQNAM::slotPollFinished()
|
|||
PollJob *job = qobject_cast<PollJob *>(sender());
|
||||
Q_ASSERT(job);
|
||||
|
||||
if (!job->_error.isEmpty()) {
|
||||
done(SyncFileItem::NormalError, job->_error);
|
||||
if (job->_item._status != SyncFileItem::Success) {
|
||||
done(job->_item._status, job->_item._errorString);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,9 +86,8 @@ class PollJob : public AbstractNetworkJob {
|
|||
QString _localPath;
|
||||
public:
|
||||
SyncFileItem _item;
|
||||
const QString _error;
|
||||
// Takes ownership of the device
|
||||
explicit PollJob(Account* account, const QString &path, SyncFileItem item,
|
||||
explicit PollJob(Account* account, const QString &path, const SyncFileItem &item,
|
||||
SyncJournalDb *journal, const QString &localPath, QObject *parent)
|
||||
: AbstractNetworkJob(account, path, parent), _journal(journal), _localPath(localPath), _item(item) {}
|
||||
|
||||
|
|
|
@ -445,6 +445,7 @@ void SyncEngine::startSync()
|
|||
CleanupPollsJob *job = new CleanupPollsJob(pollInfos, AccountManager::instance()->account(),
|
||||
_journal, _localPath, this);
|
||||
connect(job, SIGNAL(finished()), this, SLOT(startSync()));
|
||||
connect(job, SIGNAL(aborted(QString)), this, SLOT(slotCleanPollsJobAborted(QString)));
|
||||
job->start();
|
||||
return;
|
||||
}
|
||||
|
@ -623,6 +624,12 @@ void SyncEngine::slotUpdateFinished(int updateResult)
|
|||
_propagator->start(_syncedItems);
|
||||
}
|
||||
|
||||
void SyncEngine::slotCleanPollsJobAborted(const QString &error)
|
||||
{
|
||||
csyncError(error);
|
||||
finalize();
|
||||
}
|
||||
|
||||
void SyncEngine::setNetworkLimits(int upload, int download)
|
||||
{
|
||||
_uploadLimit = upload;
|
||||
|
|
|
@ -93,6 +93,7 @@ private slots:
|
|||
void slotProgress(const SyncFileItem& item, quint64 curent);
|
||||
void slotAdjustTotalTransmissionSize(qint64 change);
|
||||
void slotUpdateFinished(int updateResult);
|
||||
void slotCleanPollsJobAborted(const QString &error);
|
||||
|
||||
private:
|
||||
void handleSyncError(CSYNC *ctx, const char *state);
|
||||
|
|
|
@ -204,7 +204,7 @@ bool SyncJournalDb::checkConnect()
|
|||
}
|
||||
|
||||
createQuery.prepare("CREATE TABLE IF NOT EXISTS version("
|
||||
"major VARCHAR(4096),"
|
||||
"major INTEGER(8),"
|
||||
"minor INTEGER(8),"
|
||||
"patch INTEGER(8),"
|
||||
"custom VARCHAR(256)"
|
||||
|
|
Loading…
Reference in a new issue