mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Activity: Skip PropagateDirectory jobs #3580
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.
This commit is contained in:
parent
6152ce4187
commit
fe42c1a818
11 changed files with 45 additions and 28 deletions
|
@ -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)));
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "syncfileitem.h"
|
||||
#include "folder.h"
|
||||
#include "openfilemanager.h"
|
||||
#include "owncloudpropagator.h"
|
||||
|
||||
#include "ui_protocolwidget.h"
|
||||
|
||||
|
@ -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)));
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
|
||||
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:
|
||||
|
|
|
@ -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 &)));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -655,7 +656,7 @@ void PropagateDirectory::finalize()
|
|||
}
|
||||
}
|
||||
_state = Finished;
|
||||
emit completed(*_item);
|
||||
emit completed(*_item, *this);
|
||||
emit finished(_hasError == SyncFileItem::NoStatus ? SyncFileItem::Success : _hasError);
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ signals:
|
|||
/**
|
||||
* 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
|
||||
|
@ -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++;
|
||||
|
@ -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();
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
namespace OCC {
|
||||
|
||||
class PropagatorJob;
|
||||
|
||||
/**
|
||||
* @brief The ProgressInfo class
|
||||
* @ingroup libsync
|
||||
|
@ -239,7 +241,9 @@ signals:
|
|||
/**
|
||||
* @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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)));
|
||||
|
@ -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;
|
||||
|
@ -870,7 +870,7 @@ void SyncEngine::slotJobCompleted(const SyncFileItem &item)
|
|||
}
|
||||
|
||||
emit transmissionProgress(*_progressInfo);
|
||||
emit jobCompleted(item);
|
||||
emit jobCompleted(item, job);
|
||||
}
|
||||
|
||||
void SyncEngine::slotFinished()
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace OCC {
|
|||
class SyncJournalFileRecord;
|
||||
class SyncJournalDb;
|
||||
class OwncloudPropagator;
|
||||
class PropagatorJob;
|
||||
|
||||
/**
|
||||
* @brief The SyncEngine class
|
||||
|
@ -101,7 +102,7 @@ signals:
|
|||
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&);
|
||||
|
@ -121,7 +122,7 @@ signals:
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue