Assign empty completion when receiving 404 response
This commit is contained in:
parent
9ae7f4a265
commit
46099abc0c
|
@ -271,6 +271,8 @@ private Q_SLOTS:
|
||||||
void readLocalFolderCompletion(CppUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index);
|
void readLocalFolderCompletion(CppUtilities::DateTime eventTime, const QJsonObject &eventData, SyncthingDir &dirInfo, int index);
|
||||||
void readRemoteFolderCompletion(CppUtilities::DateTime eventTime, const QJsonObject &eventData, const QString &devId, SyncthingDev *devInfo,
|
void readRemoteFolderCompletion(CppUtilities::DateTime eventTime, const QJsonObject &eventData, const QString &devId, SyncthingDev *devInfo,
|
||||||
int devIndex, const QString &dirId, SyncthingDir *dirInfo, int dirIndex);
|
int devIndex, const QString &dirId, SyncthingDir *dirInfo, int dirIndex);
|
||||||
|
void readRemoteFolderCompletion(const SyncthingCompletion &completion, const QString &devId, SyncthingDev *devInfo, int devIndex,
|
||||||
|
const QString &dirId, SyncthingDir *dirInfo, int dirIndex);
|
||||||
void readRemoteIndexUpdated(CppUtilities::DateTime eventTime, const QJsonObject &eventData);
|
void readRemoteIndexUpdated(CppUtilities::DateTime eventTime, const QJsonObject &eventData);
|
||||||
void readPostConfig();
|
void readPostConfig();
|
||||||
void readRescan();
|
void readRescan();
|
||||||
|
|
|
@ -1159,6 +1159,14 @@ void SyncthingConnection::readCompletion()
|
||||||
emitError(tr("Unable to parse completion for device/directory %1/%2: ").arg(devId, dirId), jsonError, reply, response);
|
emitError(tr("Unable to parse completion for device/directory %1/%2: ").arg(devId, dirId), jsonError, reply, response);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case QNetworkReply::ContentNotFoundError:
|
||||||
|
// assign empty completion when receiving 404 response
|
||||||
|
// note: The connector generally tries to avoid requesting the completion for paused dirs/devs but if the completion is requested
|
||||||
|
// before it is aware that the dir/dev is paused it might still run into this error, e.g. when pausing a directory and completion
|
||||||
|
// is requested concurrently. Before Syncthing v1.15.0 we've got an empty completion instead of 404 anyways.
|
||||||
|
readRemoteFolderCompletion(SyncthingCompletion(), devId, devInfo, devIndex, dirId, dirInfo, dirIndex);
|
||||||
|
concludeConnection();
|
||||||
|
return;
|
||||||
case QNetworkReply::OperationCanceledError:
|
case QNetworkReply::OperationCanceledError:
|
||||||
handleAdditionalRequestCanceled();
|
handleAdditionalRequestCanceled();
|
||||||
break;
|
break;
|
||||||
|
@ -2023,6 +2031,16 @@ void SyncthingConnection::readRemoteFolderCompletion(DateTime eventTime, const Q
|
||||||
needed.items = jsonValueToInt(eventData.value(QLatin1String("needItems")), static_cast<double>(needed.items));
|
needed.items = jsonValueToInt(eventData.value(QLatin1String("needItems")), static_cast<double>(needed.items));
|
||||||
needed.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), static_cast<double>(needed.deletes));
|
needed.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), static_cast<double>(needed.deletes));
|
||||||
|
|
||||||
|
// update dir and dev info
|
||||||
|
readRemoteFolderCompletion(completion, devId, devInfo, devIndex, dirId, dirInfo, dirIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Reads \a completion (parsed from results of requestEvents()).
|
||||||
|
*/
|
||||||
|
void SyncthingConnection::readRemoteFolderCompletion(const SyncthingCompletion &completion, const QString &devId, SyncthingDev *devInfo, int devIndex,
|
||||||
|
const QString &dirId, SyncthingDir *dirInfo, int dirIndex)
|
||||||
|
{
|
||||||
// update dir info
|
// update dir info
|
||||||
if (dirInfo) {
|
if (dirInfo) {
|
||||||
auto &previousCompletion = dirInfo->completionByDevice[devId];
|
auto &previousCompletion = dirInfo->completionByDevice[devId];
|
||||||
|
@ -2031,11 +2049,10 @@ void SyncthingConnection::readRemoteFolderCompletion(DateTime eventTime, const Q
|
||||||
const auto previousGlobalBytes = previousCompletion.globalBytes;
|
const auto previousGlobalBytes = previousCompletion.globalBytes;
|
||||||
previousCompletion = completion;
|
previousCompletion = completion;
|
||||||
emit dirStatusChanged(*dirInfo, dirIndex);
|
emit dirStatusChanged(*dirInfo, dirIndex);
|
||||||
if (devInfo && needed.isNull() && previouslyUpdated && (previouslyNeeded || previousGlobalBytes != completion.globalBytes)) {
|
if (devInfo && completion.needed.isNull() && previouslyUpdated && (previouslyNeeded || previousGlobalBytes != completion.globalBytes)) {
|
||||||
emit dirCompleted(DateTime::gmtNow(), *dirInfo, dirIndex, devInfo);
|
emit dirCompleted(DateTime::gmtNow(), *dirInfo, dirIndex, devInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update dev info
|
// update dev info
|
||||||
if (devInfo) {
|
if (devInfo) {
|
||||||
auto &previousCompletion = devInfo->completionByDir[dirId];
|
auto &previousCompletion = devInfo->completionByDir[dirId];
|
||||||
|
|
Loading…
Reference in New Issue