mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-16 02:31:37 +03:00
Long running put: fix some bugs
This commit is contained in:
parent
550d6d66d1
commit
8df14ee845
3 changed files with 25 additions and 8 deletions
|
@ -87,7 +87,11 @@ void PUTFileJob::slotTimeout() {
|
||||||
void PollJob::start()
|
void PollJob::start()
|
||||||
{
|
{
|
||||||
setTimeout(30 * 1000);
|
setTimeout(30 * 1000);
|
||||||
setReply(davRequest("GET", path()));
|
QUrl accountUrl = account()->url();
|
||||||
|
QUrl finalUrl = QUrl::fromUserInput(accountUrl.scheme() + QLatin1String("://") + accountUrl.authority()
|
||||||
|
+ (path().startsWith('/') ? QLatin1String("") : QLatin1Literal("/")) + path());
|
||||||
|
setReply(getRequest(finalUrl));
|
||||||
|
setupConnections(reply());
|
||||||
connect(reply(), SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(resetTimeout()));
|
connect(reply(), SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(resetTimeout()));
|
||||||
AbstractNetworkJob::start();
|
AbstractNetworkJob::start();
|
||||||
}
|
}
|
||||||
|
@ -99,7 +103,14 @@ bool PollJob::finished()
|
||||||
_item._httpErrorCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
_item._httpErrorCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
_item._status = classifyError(err, _item._httpErrorCode);
|
_item._status = classifyError(err, _item._httpErrorCode);
|
||||||
_item._errorString = reply()->errorString();
|
_item._errorString = reply()->errorString();
|
||||||
if (_item._status == SyncFileItem::FatalError || int(_item._httpErrorCode / 100) == 4) {
|
if (_item._status == SyncFileItem::FatalError || _item._httpErrorCode >= 400) {
|
||||||
|
if (_item._status != SyncFileItem::FatalError) {
|
||||||
|
SyncJournalDb::PollInfo info;
|
||||||
|
info._file = _item._file;
|
||||||
|
// no info._url removes it from the database
|
||||||
|
_journal->setPollInfo(info);
|
||||||
|
|
||||||
|
}
|
||||||
emit finishedSignal();
|
emit finishedSignal();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +133,7 @@ bool PollJob::finished()
|
||||||
}
|
}
|
||||||
|
|
||||||
_item._errorString = status["error"].toString();
|
_item._errorString = status["error"].toString();
|
||||||
_item._status = _item._errorString.isEmpty() ? SyncFileItem::NormalError : SyncFileItem::Success;
|
_item._status = _item._errorString.isEmpty() ? SyncFileItem::Success : SyncFileItem::NormalError;
|
||||||
_item._fileId = status["fileid"].toByteArray();
|
_item._fileId = status["fileid"].toByteArray();
|
||||||
_item._etag = status["etag"].toByteArray();
|
_item._etag = status["etag"].toByteArray();
|
||||||
_item._responseTimeStamp = responseTimestamp();
|
_item._responseTimeStamp = responseTimestamp();
|
||||||
|
@ -350,7 +361,7 @@ void PropagateUploadFileQNAM::slotPutFinished()
|
||||||
_item._httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
_item._httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
// The server needs some time to process the request and provide with a poll URL
|
// The server needs some time to process the request and provide with a poll URL
|
||||||
if (_item._httpErrorCode == 202) {
|
if (_item._httpErrorCode == 202) {
|
||||||
QString path = QString::fromUtf8(QByteArray::fromPercentEncoding(job->reply()->rawHeader("OC-Finish-Poll")));
|
QString path = QString::fromUtf8(job->reply()->rawHeader("OC-Finish-Poll"));
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
_propagator->_activeJobs--;
|
_propagator->_activeJobs--;
|
||||||
done(SyncFileItem::NormalError, tr("Poll URL missing"));
|
done(SyncFileItem::NormalError, tr("Poll URL missing"));
|
||||||
|
@ -461,6 +472,7 @@ void PropagateUploadFileQNAM::startPollJob(const QString& path)
|
||||||
info._url = path;
|
info._url = path;
|
||||||
info._modtime = _item._modtime;
|
info._modtime = _item._modtime;
|
||||||
_propagator->_journal->setPollInfo(info);
|
_propagator->_journal->setPollInfo(info);
|
||||||
|
job->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropagateUploadFileQNAM::slotPollFinished()
|
void PropagateUploadFileQNAM::slotPollFinished()
|
||||||
|
|
|
@ -96,6 +96,7 @@ public:
|
||||||
void slotTimeout() Q_DECL_OVERRIDE {
|
void slotTimeout() Q_DECL_OVERRIDE {
|
||||||
// emit finishedSignal(false);
|
// emit finishedSignal(false);
|
||||||
// deleteLater();
|
// deleteLater();
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
reply()->abort();
|
reply()->abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -834,10 +834,10 @@ QVector< SyncJournalDb::PollInfo > SyncJournalDb::getPollInfos()
|
||||||
|
|
||||||
QVector< SyncJournalDb::PollInfo > res;
|
QVector< SyncJournalDb::PollInfo > res;
|
||||||
|
|
||||||
if( checkConnect() )
|
if( !checkConnect() )
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
QSqlQuery query("SELECT path, mtime, pollpath FROM poll",_db);
|
QSqlQuery query("SELECT path, modtime, pollpath FROM poll",_db);
|
||||||
|
|
||||||
if (!query.exec()) {
|
if (!query.exec()) {
|
||||||
QString err = query.lastError().text();
|
QString err = query.lastError().text();
|
||||||
|
@ -851,7 +851,11 @@ QVector< SyncJournalDb::PollInfo > SyncJournalDb::getPollInfos()
|
||||||
info._modtime = query.value(1).toLongLong();
|
info._modtime = query.value(1).toLongLong();
|
||||||
info._url = query.value(2).toString();
|
info._url = query.value(2).toString();
|
||||||
res.append(info);
|
res.append(info);
|
||||||
|
qDebug() << "§§§§§§§§§§§§§§§§" << info._file << info._url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "§§§§§§§§§-*-*-*§§§§§§§" << res.count();
|
||||||
|
|
||||||
query.finish();
|
query.finish();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -863,7 +867,7 @@ void SyncJournalDb::setPollInfo(const SyncJournalDb::PollInfo& info)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info._file.isEmpty()) {
|
if (info._url.isEmpty()) {
|
||||||
QSqlQuery query("DELETE FROM poll WHERE path=?", _db);
|
QSqlQuery query("DELETE FROM poll WHERE path=?", _db);
|
||||||
query.bindValue(0, info._file);
|
query.bindValue(0, info._file);
|
||||||
if( !query.exec() ) {
|
if( !query.exec() ) {
|
||||||
|
@ -872,7 +876,7 @@ void SyncJournalDb::setPollInfo(const SyncJournalDb::PollInfo& info)
|
||||||
qDebug() << query.executedQuery() << info._file;
|
qDebug() << query.executedQuery() << info._file;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QSqlQuery query("INSERT OR REPLACE INTO poll (path, mtime, pollpath) VALUES( ? , ? , ? )", _db);
|
QSqlQuery query("INSERT OR REPLACE INTO poll (path, modtime, pollpath) VALUES( ? , ? , ? )", _db);
|
||||||
query.bindValue(0, info._file);
|
query.bindValue(0, info._file);
|
||||||
query.bindValue(1, QString::number(info._modtime));
|
query.bindValue(1, QString::number(info._modtime));
|
||||||
query.bindValue(2, info._url);
|
query.bindValue(2, info._url);
|
||||||
|
|
Loading…
Reference in a new issue