Skip to content

Commit

Permalink
Activity: Skip PropagateDirectory jobs owncloud#3580
Browse files Browse the repository at this point in the history
Previously, PropagateDirectory jobs didn't emit the completed() signal.
Now that they do, we need to make sure to not add extra lines to the
protocol widget for them.

To accomplish that, the jobCompleted() signal now also contains the job
that completed the item.
  • Loading branch information
ckamm committed Aug 11, 2015
1 parent 6152ce4 commit fe42c1a
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 28 deletions.
7 changes: 4 additions & 3 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,8 @@ void Folder::startSync(const QStringList &pathList)
SLOT(slotAboutToRemoveAllFiles(SyncFileItem::Direction,bool*)));
connect(_engine.data(), SIGNAL(folderDiscovered(bool,QString)), this, SLOT(slotFolderDiscovered(bool,QString)));
connect(_engine.data(), SIGNAL(transmissionProgress(ProgressInfo)), this, SLOT(slotTransmissionProgress(ProgressInfo)));
connect(_engine.data(), SIGNAL(jobCompleted(const SyncFileItem &)), this, SLOT(slotJobCompleted(const SyncFileItem &)));
connect(_engine.data(), SIGNAL(jobCompleted(const SyncFileItem &, const PropagatorJob &)),
this, SLOT(slotJobCompleted(const SyncFileItem &, const PropagatorJob &)));
connect(_engine.data(), SIGNAL(syncItemDiscovered(const SyncFileItem &)), this, SLOT(slotSyncItemDiscovered(const SyncFileItem &)));
connect(_engine.data(), SIGNAL(newBigFolder(QString)), this, SLOT(slotNewBigFolderDiscovered(QString)));

Expand Down Expand Up @@ -1047,7 +1048,7 @@ void Folder::slotTransmissionProgress(const ProgressInfo &pi)
}

// a job is completed: count the errors and forward to the ProgressDispatcher
void Folder::slotJobCompleted(const SyncFileItem &item)
void Folder::slotJobCompleted(const SyncFileItem &item, const PropagatorJob& job)
{
if (item.hasErrorStatus()) {
_stateLastSyncItemsWithError.insert(item._file);
Expand All @@ -1057,7 +1058,7 @@ void Folder::slotJobCompleted(const SyncFileItem &item)
// Count all error conditions.
_syncResult.setWarnCount(_syncResult.warnCount()+1);
}
emit ProgressDispatcher::instance()->jobCompleted(alias(), item);
emit ProgressDispatcher::instance()->jobCompleted(alias(), item, job);
}

void Folder::slotSyncItemDiscovered(const SyncFileItem & item)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private slots:

void slotFolderDiscovered(bool local, QString folderName);
void slotTransmissionProgress(const ProgressInfo& pi);
void slotJobCompleted(const SyncFileItem&);
void slotJobCompleted(const SyncFileItem&, const PropagatorJob&);
void slotSyncItemDiscovered(const SyncFileItem & item);

void slotRunEtagJob();
Expand Down
19 changes: 13 additions & 6 deletions src/gui/protocolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "syncfileitem.h"
#include "folder.h"
#include "openfilemanager.h"
#include "owncloudpropagator.h"

#include "ui_protocolwidget.h"

Expand All @@ -42,6 +43,8 @@ ProtocolWidget::ProtocolWidget(QWidget *parent) :

connect(ProgressDispatcher::instance(), SIGNAL(progressInfo(QString,ProgressInfo)),
this, SLOT(slotProgressInfo(QString,ProgressInfo)));
connect(ProgressDispatcher::instance(), SIGNAL(jobCompleted(QString,SyncFileItem,PropagatorJob)),
this, SLOT(slotJobComplete(QString,SyncFileItem,PropagatorJob)));

connect(_ui->_treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), SLOT(slotOpenFile(QTreeWidgetItem*,int)));

Expand Down Expand Up @@ -276,17 +279,21 @@ void ProtocolWidget::slotProgressInfo( const QString& folder, const ProgressInfo
//Sync completed
computeResyncButtonEnabled();
}
SyncFileItem last = progress._lastCompletedItem;
if (last.isEmpty()) return;
}

QTreeWidgetItem *item = createCompletedTreewidgetItem(folder, last);
if(item) {
_ui->_treeWidget->insertTopLevelItem(0, item);
void ProtocolWidget::slotJobComplete(const QString &folder, const SyncFileItem &item, const PropagatorJob &job)
{
if (qobject_cast<const PropagateDirectory*>(&job)) {
return;
}

QTreeWidgetItem *line = createCompletedTreewidgetItem(folder, item);
if(line) {
_ui->_treeWidget->insertTopLevelItem(0, line);
if (!_copyBtn->isEnabled()) {
_copyBtn->setEnabled(true);
}
}
}


}
1 change: 1 addition & 0 deletions src/gui/protocolwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ProtocolWidget : public QWidget

public slots:
void slotProgressInfo( const QString& folder, const ProgressInfo& progress );
void slotJobComplete( const QString& folder, const SyncFileItem& item, const PropagatorJob& job);
void slotOpenFile( QTreeWidgetItem* item, int );

protected slots:
Expand Down
2 changes: 1 addition & 1 deletion src/gui/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ SocketApi::SocketApi(QObject* parent)

// folder watcher
connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(Folder*)), this, SLOT(slotUpdateFolderView(Folder*)));
connect(ProgressDispatcher::instance(), SIGNAL(jobCompleted(QString, const SyncFileItem &)),
connect(ProgressDispatcher::instance(), SIGNAL(jobCompleted(QString, const SyncFileItem &, const PropagatorJob &)),
SLOT(slotJobCompleted(QString, const SyncFileItem &)));
connect(ProgressDispatcher::instance(), SIGNAL(syncItemDiscovered(QString, const SyncFileItem &)),
this, SLOT(slotSyncItemDiscovered(QString, const SyncFileItem &)));
Expand Down
13 changes: 7 additions & 6 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void PropagateItemJob::done(SyncFileItem::Status status, const QString &errorStr

_item->_status = status;

emit completed(*_item);
emit completed(*_item, *this);
emit finished(status);
}

Expand Down Expand Up @@ -187,8 +187,8 @@ bool PropagateItemJob::checkForProblemsWithShared(int httpStatusCode, const QStr
if( newJob ) {
newJob->setRestoreJobMsg(msg);
_restoreJob.reset(newJob);
connect(_restoreJob.data(), SIGNAL(completed(const SyncFileItemPtr &)),
this, SLOT(slotRestoreJobCompleted(const SyncFileItemPtr &)));
connect(_restoreJob.data(), SIGNAL(completed(const SyncFileItemPtr &, const PropagatorJob &)),
this, SLOT(slotRestoreJobCompleted(const SyncFileItemPtr &, const PropagatorJob &)));
QMetaObject::invokeMethod(newJob, "start");
}
return true;
Expand Down Expand Up @@ -354,7 +354,8 @@ void OwncloudPropagator::start(const SyncFileItemVector& items)
_rootJob->append(it);
}

connect(_rootJob.data(), SIGNAL(completed(const SyncFileItem &)), this, SIGNAL(completed(const SyncFileItem &)));
connect(_rootJob.data(), SIGNAL(completed(const SyncFileItem &, const PropagatorJob &)),
this, SIGNAL(completed(const SyncFileItem &, const PropagatorJob &)));
connect(_rootJob.data(), SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
connect(_rootJob.data(), SIGNAL(finished(SyncFileItem::Status)), this, SLOT(emitFinished()));
connect(_rootJob.data(), SIGNAL(ready()), this, SLOT(scheduleNextJob()), Qt::QueuedConnection);
Expand Down Expand Up @@ -611,7 +612,7 @@ void PropagateDirectory::slotSubJobFinished(SyncFileItem::Status status)
(sender() == _firstJob.data() && status != SyncFileItem::Success && status != SyncFileItem::Restoration)) {
abort();
_state = Finished;
emit completed(*_item);
emit completed(*_item, *this);
emit finished(status);
return;
} else if (status == SyncFileItem::NormalError || status == SyncFileItem::SoftError) {
Expand Down Expand Up @@ -655,7 +656,7 @@ void PropagateDirectory::finalize()
}
}
_state = Finished;
emit completed(*_item);
emit completed(*_item, *this);
emit finished(_hasError == SyncFileItem::NoStatus ? SyncFileItem::Success : _hasError);
}

Expand Down
7 changes: 4 additions & 3 deletions src/libsync/owncloudpropagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public slots:
/**
* Emitted when one item has been completed within a job.
*/
void completed(const SyncFileItem &);
void completed(const SyncFileItem &, const PropagatorJob &);

/**
* Emitted when all the sub-jobs have been finished and
Expand Down Expand Up @@ -207,7 +207,8 @@ private slots:
bool possiblyRunNextJob(PropagatorJob *next) {
if (next->_state == NotYetStarted) {
connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)), Qt::QueuedConnection);
connect(next, SIGNAL(completed(const SyncFileItem &)), this, SIGNAL(completed(const SyncFileItem &)));
connect(next, SIGNAL(completed(const SyncFileItem &, const PropagatorJob &)),
this, SIGNAL(completed(const SyncFileItem &, const PropagatorJob &)));
connect(next, SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
connect(next, SIGNAL(ready()), this, SIGNAL(ready()));
_runningNow++;
Expand Down Expand Up @@ -333,7 +334,7 @@ private slots:
void scheduleNextJob();

signals:
void completed(const SyncFileItem &);
void completed(const SyncFileItem &, const PropagatorJob &);
void progress(const SyncFileItem&, quint64 bytes);
void finished();
/**
Expand Down
6 changes: 5 additions & 1 deletion src/libsync/progressdispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

namespace OCC {

class PropagatorJob;

/**
* @brief The ProgressInfo class
* @ingroup libsync
Expand Down Expand Up @@ -239,7 +241,9 @@ class OWNCLOUDSYNC_EXPORT ProgressDispatcher : public QObject
/**
* @brief: the item's job is completed
*/
void jobCompleted(const QString &folder, const SyncFileItem & item);
void jobCompleted(const QString &folder,
const SyncFileItem & item,
const PropagatorJob & job);

void syncItemDiscovered(const QString &folder, const SyncFileItem & item);

Expand Down
3 changes: 2 additions & 1 deletion src/libsync/propagateupload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ void PropagateUploadFileQNAM::slotPutFinished()
qWarning() << "Server do not support X-OC-MTime" << job->reply()->rawHeader("X-OC-MTime");
#ifdef USE_NEON
PropagatorJob *newJob = new UpdateMTimeAndETagJob(_propagator, _item);
QObject::connect(newJob, SIGNAL(completed(SyncFileItem)), this, SLOT(finalize(SyncFileItem)));
QObject::connect(newJob, SIGNAL(completed(SyncFileItem, PropagatorJob)),
this, SLOT(finalize(SyncFileItem)));
QMetaObject::invokeMethod(newJob, "start");
return;
#else
Expand Down
8 changes: 4 additions & 4 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)

_propagator = QSharedPointer<OwncloudPropagator>(
new OwncloudPropagator (_account, session, _localPath, _remoteUrl, _remotePath, _journal, &_thread));
connect(_propagator.data(), SIGNAL(completed(const SyncFileItem &)),
this, SLOT(slotJobCompleted(const SyncFileItem &)));
connect(_propagator.data(), SIGNAL(completed(const SyncFileItem &, const PropagatorJob &)),
this, SLOT(slotJobCompleted(const SyncFileItem &, const PropagatorJob &)));
connect(_propagator.data(), SIGNAL(progress(const SyncFileItem &,quint64)),
this, SLOT(slotProgress(const SyncFileItem &,quint64)));
connect(_propagator.data(), SIGNAL(adjustTotalTransmissionSize(qint64)), this, SLOT(slotAdjustTotalTransmissionSize(qint64)));
Expand Down Expand Up @@ -858,7 +858,7 @@ void SyncEngine::setNetworkLimits(int upload, int download)
}
}

void SyncEngine::slotJobCompleted(const SyncFileItem &item)
void SyncEngine::slotJobCompleted(const SyncFileItem &item, const PropagatorJob &job)
{
const char * instruction_str = csync_instruction_str(item._instruction);
qDebug() << Q_FUNC_INFO << item._file << instruction_str << item._status << item._errorString;
Expand All @@ -870,7 +870,7 @@ void SyncEngine::slotJobCompleted(const SyncFileItem &item)
}

emit transmissionProgress(*_progressInfo);
emit jobCompleted(item);
emit jobCompleted(item, job);
}

void SyncEngine::slotFinished()
Expand Down
5 changes: 3 additions & 2 deletions src/libsync/syncengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace OCC {
class SyncJournalFileRecord;
class SyncJournalDb;
class OwncloudPropagator;
class PropagatorJob;

/**
* @brief The SyncEngine class
Expand Down Expand Up @@ -101,7 +102,7 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject
void aboutToPropagate(SyncFileItemVector&);

// after each job (successful or not)
void jobCompleted(const SyncFileItem&);
void jobCompleted(const SyncFileItem&, const PropagatorJob&);

// after sync is done
void treeWalkResult(const SyncFileItemVector&);
Expand All @@ -121,7 +122,7 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject

private slots:
void slotRootEtagReceived(QString);
void slotJobCompleted(const SyncFileItem& item);
void slotJobCompleted(const SyncFileItem& item, const PropagatorJob & job);
void slotFinished();
void slotProgress(const SyncFileItem& item, quint64 curent);
void slotAdjustTotalTransmissionSize(qint64 change);
Expand Down

0 comments on commit fe42c1a

Please sign in to comment.