mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Error counting added
This commit is contained in:
parent
defda477c4
commit
ace9e9d690
4 changed files with 57 additions and 20 deletions
|
@ -30,6 +30,7 @@ namespace Mirall {
|
|||
|
||||
Folder::Folder(const QString &alias, const QString &path, QObject *parent)
|
||||
: QObject(parent),
|
||||
_errorCount(0),
|
||||
_path(path),
|
||||
_pollTimer(new QTimer(this)),
|
||||
_pollInterval(DEFAULT_POLL_INTERVAL_SEC),
|
||||
|
@ -112,13 +113,37 @@ void Folder::setPollInterval(int seconds)
|
|||
_pollInterval = seconds;
|
||||
}
|
||||
|
||||
int Folder::errorCount()
|
||||
{
|
||||
return _errorCount;
|
||||
}
|
||||
|
||||
void Folder::resetErrorCount()
|
||||
{
|
||||
_errorCount = 0;
|
||||
}
|
||||
|
||||
void Folder::incrementErrorCount()
|
||||
{
|
||||
// if the error count gets higher than three, the interval timer
|
||||
// of the watcher is doubled.
|
||||
_errorCount++;
|
||||
if( _errorCount > 1 ) {
|
||||
int interval = _watcher->eventInterval();
|
||||
int newInt = 2*interval;
|
||||
qDebug() << "Set new watcher interval to " << newInt;
|
||||
_watcher->setEventInterval( newInt );
|
||||
_errorCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Folder::evaluateSync(const QStringList &pathList)
|
||||
{
|
||||
if (!_online && onlyOnlineEnabled()) {
|
||||
qDebug() << "*" << alias() << "sync skipped, not online";
|
||||
return;
|
||||
}
|
||||
startSync(pathList);
|
||||
if (!_online && onlyOnlineEnabled()) {
|
||||
qDebug() << "*" << alias() << "sync skipped, not online";
|
||||
return;
|
||||
}
|
||||
startSync(pathList);
|
||||
}
|
||||
|
||||
void Folder::slotPollTimerTimeout()
|
||||
|
|
|
@ -88,6 +88,16 @@ public:
|
|||
void setOnlyThisLANEnabled(bool enabled);
|
||||
|
||||
|
||||
/**
|
||||
* error counter, stop syncing after the counter reaches a certain
|
||||
* number.
|
||||
*/
|
||||
int errorCount();
|
||||
|
||||
void resetErrorCount();
|
||||
|
||||
void incrementErrorCount();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The minimum amounts of seconds to wait before
|
||||
|
@ -108,6 +118,7 @@ signals:
|
|||
|
||||
protected:
|
||||
FolderWatcher *_watcher;
|
||||
int _errorCount;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace Mirall {
|
|||
const QString &secondPath,
|
||||
QObject *parent)
|
||||
: Folder(alias, path, parent),
|
||||
_SiteCopy(new QProcess(this)),
|
||||
_syncCount(0)
|
||||
_SiteCopy(new QProcess(this)),
|
||||
_syncCount(0)
|
||||
{
|
||||
QObject::connect(_SiteCopy, SIGNAL(readyReadStandardOutput()),
|
||||
SLOT(slotReadyReadStandardOutput()));
|
||||
|
@ -112,15 +112,19 @@ void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||
|
||||
if( exitCode == -1 ) {
|
||||
qDebug() << "Configuration Error, stop processing.";
|
||||
emit( syncFinished( SyncResult( SyncResult::Error )));
|
||||
SyncResult res( SyncResult::Error );
|
||||
res.setErrorString( tr("Sitecopy configuration problem, check $HOME/.sitecopyrc"));
|
||||
incrementErrorCount();
|
||||
emit( syncFinished( res ));
|
||||
}
|
||||
|
||||
if( exitCode > 0 ) {
|
||||
if( exitCode > 1 ) {
|
||||
// error has happened.
|
||||
QString out( _lastOutput );
|
||||
SyncResult res( SyncResult::Error );
|
||||
res.setErrorString( out );
|
||||
qDebug() << "An error happened: " << out;
|
||||
incrementErrorCount();
|
||||
emit syncFinished( res );
|
||||
return;
|
||||
}
|
||||
|
@ -132,10 +136,7 @@ void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||
startSiteCopy( "--update", Finish ); // update from owncloud
|
||||
} else if( _NextStep == Finish ) {
|
||||
qDebug() << "Finished!";
|
||||
|
||||
emit syncFinished((exitCode == -1 ) ?
|
||||
SyncResult(SyncResult::Error)
|
||||
: SyncResult(SyncResult::Success));
|
||||
emit syncFinished( SyncResult(SyncResult::Success) );
|
||||
// mLocalChangesSeen = false;
|
||||
} else if( _NextStep == Status ) {
|
||||
startSiteCopy( "--flatlist", DisplayStatus );
|
||||
|
@ -149,7 +150,7 @@ void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||
// No update needed
|
||||
emit syncFinished( SyncResult( SyncResult::Success ) );
|
||||
} else {
|
||||
qDebug() << "Got an invalid exit code " << exitCode;
|
||||
qDebug() << "Got an unknown exit code " << exitCode;
|
||||
emit syncFinished( SyncResult( SyncResult::Error ) );
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +163,7 @@ void SiteCopyFolder::analyzeStatus()
|
|||
QString out( _lastOutput );
|
||||
qDebug() << "Output: " << out;
|
||||
|
||||
mChangesHash.clear();
|
||||
_ChangesHash.clear();
|
||||
|
||||
QStringList items;
|
||||
QString action;
|
||||
|
@ -175,7 +176,7 @@ void SiteCopyFolder::analyzeStatus()
|
|||
}
|
||||
if( l.startsWith( "sectend|")) {
|
||||
action = l.mid(8);
|
||||
mChangesHash.insert( action, items );
|
||||
_ChangesHash.insert( action, items );
|
||||
items.clear();
|
||||
}
|
||||
if( l.startsWith( "item|" )) {
|
||||
|
|
|
@ -62,11 +62,11 @@ private:
|
|||
QProcess *_SiteCopy;
|
||||
int _syncCount;
|
||||
|
||||
QByteArray _lastOutput;
|
||||
QString _StatusString;
|
||||
QByteArray _lastOutput;
|
||||
QString _StatusString;
|
||||
SiteCopyState _NextStep;
|
||||
QString _siteCopyAlias;
|
||||
QHash<QString, QStringList> mChangesHash;
|
||||
QString _siteCopyAlias;
|
||||
QHash<QString, QStringList> _ChangesHash;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue