void ownCloudFolder::slotCSyncFinished() { if (_csync->error()) qDebug() << " * owncloud csync thread finished with error"; else qDebug() << " * owncloud csync thread finished successfully"; #ifndef USE_WATCHER if( _csync->hasLocalChanges( _lastWalkedFiles ) ) { qDebug() << "Last walked files: " << _lastWalkedFiles << " against " << _csync->walkedFiles(); qDebug() << "*** Local changes, lets do a full sync!" ; _localCheckOnly = false; _pollTimerCnt = 0; _lastWalkedFiles = -1; QTimer::singleShot( 0, this, SLOT(startSync( QStringList() ))); } else { qDebug() << " *** Finalize, pollTimerCounter is "<< _pollTimerCnt ; _lastWalkedFiles = _csync->walkedFiles(); // TODO delete thread } #endif emit syncFinished(_csync->error() ? SyncResult(SyncResult::Error) : SyncResult(SyncResult::Success)); }
void SiteCopyFolder::analyzeStatus() { QString out( _lastOutput ); qDebug() << "Output: " << out; _ChangesHash.clear(); QStringList items; QString action; QStringList li = out.split(QChar('\n')); foreach( QString l, li ) { if( l.startsWith( "sectstart|") ) { action = l.mid(10); qDebug() << "starting to parse " << action; } if( l.startsWith( "sectend|")) { action = l.mid(8); _ChangesHash.insert( action, items ); items.clear(); } if( l.startsWith( "item|" )) { QString item = l.mid(5); items << item; } if( l.startsWith("siteend") ) { #if 0 if( l.endsWith("unchanged") ) { // we are synced and don't do anything // emit statusChange( Unchanged ); // FIXME: Bug handling emit syncFinished( SyncResult(SyncResult::Success) ); } else if( l.endsWith("changed")) { startSiteCopy( "--update", Status ); if( mLocalChangesSeen ) { // emit statusChange( SyncToNeeded ); } else { // emit statusChange( SyncFromNeeded ); } } #endif } } }
void SyncResult::reset() { *this = SyncResult(); }
void GitFolder::startSync() { QMutexLocker locker(&_syncMutex); emit syncStarted(); emit syncFinished(SyncResult(SyncResult::Success)); }
void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus) { qDebug() << " * SiteCopy process finished with status" << exitCode; if( exitCode == -1 ) { qDebug() << "Configuration Error, stop processing."; SyncResult res( SyncResult::Error ); res.setErrorString( tr("Sitecopy configuration problem, check $HOME/.sitecopyrc")); incrementErrorCount(); emit( syncFinished( res )); } 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; } if( _NextStep == Sync ) { startSiteCopy( "--sync", Finish ); // sync local with cloud data. } else if( _NextStep == Update ) { startSiteCopy( "--update", Finish ); // update from owncloud } else if( _NextStep == Finish ) { qDebug() << "Finished!"; emit syncFinished( SyncResult(SyncResult::Success) ); // mLocalChangesSeen = false; } else if( _NextStep == Status ) { startSiteCopy( "--fetch", FlatList ); } else if( _NextStep == FlatList ) { startSiteCopy( "--flatlist", ExecuteStatus ); } else if( _NextStep == ExecuteStatus ) { if( exitCode == 1 ) { qDebug() << "Exit-Code: Sync Needed!"; analyzeStatus(); if( _ChangesHash.contains("deleted") && _pathListEmpty ) { // problem: Files were added on the cloud. If we say update, // the new files are going to be deleted. Lets warn the user. qDebug() << "!!!! Better not call update, changes happened on the cloud!"; SyncResult res( SyncResult::Disabled ); res.setErrorString( tr("The ownCloud changed. Disabling syncing for security reasons.")); res.setSyncChanges( _ChangesHash ); setSyncEnabled( false ); emit syncFinished( res ); } else { startSiteCopy( "--update", Status ); } } else if( exitCode == 0 ) { qDebug() << "No update needed, remote is in sync."; SyncResult res( SyncResult::Success ); // store the analyze results into the sync result data structure. res.setSyncChanges( _ChangesHash ); // No update needed emit syncFinished( res ); } else { qDebug() << "Got an unknown exit code " << exitCode; emit syncFinished( SyncResult( SyncResult::Error ) ); } } _lastOutput.clear(); }