Discovery: fix double emission of finished in case of error

This commit is contained in:
Olivier Goffart 2018-11-05 13:25:31 +01:00 committed by Kevin Ottens
parent 7061f31887
commit b79e57d1c1
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 8 additions and 5 deletions

View file

@ -1149,8 +1149,6 @@ int ProcessDirectoryJob::processSubJobs(int nbJobs)
void ProcessDirectoryJob::dbError() void ProcessDirectoryJob::dbError()
{ {
_discoveryData->fatalError(tr("Error while reading the database")); _discoveryData->fatalError(tr("Error while reading the database"));
_pendingAsyncJobs = -1; // We're finished, we don't want to emit finished again
emit finished();
} }
void ProcessDirectoryJob::addVirtualFileSuffix(QString &str) const void ProcessDirectoryJob::addVirtualFileSuffix(QString &str) const
@ -1214,7 +1212,6 @@ DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery()
} }
emit _discoveryData->fatalError(tr("Server replied with an error while reading directory '%1' : %2") emit _discoveryData->fatalError(tr("Server replied with an error while reading directory '%1' : %2")
.arg(_currentFolder._server, results.errorMessage())); .arg(_currentFolder._server, results.errorMessage()));
emit finished();
} }
}); });
connect(serverJob, &DiscoverySingleDirectoryJob::firstDirectoryPermissions, this, connect(serverJob, &DiscoverySingleDirectoryJob::firstDirectoryPermissions, this,
@ -1248,7 +1245,6 @@ bool ProcessDirectoryJob::runLocalQuery()
return true; return true;
} }
emit _discoveryData->fatalError(errorString); emit _discoveryData->fatalError(errorString);
emit finished();
return false; return false;
} }
errno = 0; errno = 0;
@ -1283,7 +1279,6 @@ bool ProcessDirectoryJob::runLocalQuery()
// Note: Windows vio converts any error into EACCES // Note: Windows vio converts any error into EACCES
qCWarning(lcDisco) << "readdir failed for file in " << _currentFolder._local << " - errno: " << errno; qCWarning(lcDisco) << "readdir failed for file in " << _currentFolder._local << " - errno: " << errno;
emit _discoveryData->fatalError(tr("Error while reading directory %1").arg(_discoveryData->_localDir + _currentFolder._local)); emit _discoveryData->fatalError(tr("Error while reading directory %1").arg(_discoveryData->_localDir + _currentFolder._local));
emit finished();
return false; return false;
} }
return true; return true;

View file

@ -642,6 +642,11 @@ void SyncEngine::slotNewItem(const SyncFileItemPtr &item)
void SyncEngine::slotDiscoveryJobFinished() void SyncEngine::slotDiscoveryJobFinished()
{ {
if (!_discoveryPhase) {
// There was an error that was already taken care of
return;
}
qCInfo(lcEngine) << "#### Discovery end #################################################### " << _stopWatch.addLapTime(QLatin1String("Discovery Finished")) << "ms"; qCInfo(lcEngine) << "#### Discovery end #################################################### " << _stopWatch.addLapTime(QLatin1String("Discovery Finished")) << "ms";
// Sanity check // Sanity check
@ -817,6 +822,9 @@ void SyncEngine::finalize(bool success)
qCInfo(lcEngine) << "Sync run took " << _stopWatch.addLapTime(QLatin1String("Sync Finished")) << "ms"; qCInfo(lcEngine) << "Sync run took " << _stopWatch.addLapTime(QLatin1String("Sync Finished")) << "ms";
_stopWatch.stop(); _stopWatch.stop();
if (_discoveryPhase) {
_discoveryPhase.take()->deleteLater();
}
s_anySyncRunning = false; s_anySyncRunning = false;
_syncRunning = false; _syncRunning = false;
emit finished(success); emit finished(success);