mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
Connect the SocketApi directly to the SyncFileStatusTracker
Don't go through the Folder->ProgressDispatcher->SocketApi route and keep the path logic in SyncFileStatusTracker.
This commit is contained in:
parent
da7b9916e5
commit
ea5e6d367b
8 changed files with 42 additions and 58 deletions
|
@ -114,7 +114,6 @@ Folder::Folder(const FolderDefinition& definition,
|
|||
connect(_engine.data(), SIGNAL(transmissionProgress(ProgressInfo)), this, SLOT(slotTransmissionProgress(ProgressInfo)));
|
||||
connect(_engine.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SLOT(slotItemCompleted(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)));
|
||||
}
|
||||
|
||||
|
@ -913,11 +912,6 @@ void Folder::slotItemCompleted(const SyncFileItem &item, const PropagatorJob& jo
|
|||
emit ProgressDispatcher::instance()->itemCompleted(alias(), item, job);
|
||||
}
|
||||
|
||||
void Folder::slotSyncItemDiscovered(const SyncFileItem & item)
|
||||
{
|
||||
emit ProgressDispatcher::instance()->syncItemDiscovered(alias(), item);
|
||||
}
|
||||
|
||||
void Folder::slotNewBigFolderDiscovered(const QString &newF)
|
||||
{
|
||||
auto newFolder = newF;
|
||||
|
|
|
@ -248,7 +248,6 @@ private slots:
|
|||
void slotFolderDiscovered(bool local, QString folderName);
|
||||
void slotTransmissionProgress(const ProgressInfo& pi);
|
||||
void slotItemCompleted(const SyncFileItem&, const PropagatorJob&);
|
||||
void slotSyncItemDiscovered(const SyncFileItem & item);
|
||||
|
||||
void slotRunEtagJob();
|
||||
void etagRetreived(const QString &);
|
||||
|
|
|
@ -105,6 +105,8 @@ void FolderMan::unloadFolder( Folder *f )
|
|||
this, SLOT(slotForwardFolderSyncStateChange()));
|
||||
disconnect(f, SIGNAL(syncPausedChanged(Folder*,bool)),
|
||||
this, SLOT(slotFolderSyncPaused(Folder*,bool)));
|
||||
disconnect(&f->syncEngine().syncFileStatusTracker(), SIGNAL(fileStatusChanged(const QString &, SyncFileStatus)),
|
||||
_socketApi.data(), SLOT(slotFileStatusChanged(const QString &, SyncFileStatus)));
|
||||
}
|
||||
|
||||
int FolderMan::unloadAndDeleteAllFolders()
|
||||
|
@ -796,6 +798,8 @@ Folder* FolderMan::addFolderInternal(const FolderDefinition& folderDefinition, A
|
|||
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
|
||||
connect(folder, SIGNAL(syncStateChange()), SLOT(slotForwardFolderSyncStateChange()));
|
||||
connect(folder, SIGNAL(syncPausedChanged(Folder*,bool)), SLOT(slotFolderSyncPaused(Folder*,bool)));
|
||||
connect(&folder->syncEngine().syncFileStatusTracker(), SIGNAL(fileStatusChanged(const QString &, SyncFileStatus)),
|
||||
_socketApi.data(), SLOT(slotFileStatusChanged(const QString &, SyncFileStatus)));
|
||||
|
||||
registerFolderMonitor(folder);
|
||||
return folder;
|
||||
|
|
|
@ -114,10 +114,6 @@ SocketApi::SocketApi(QObject* parent)
|
|||
|
||||
// folder watcher
|
||||
connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(Folder*)), this, SLOT(slotUpdateFolderView(Folder*)));
|
||||
connect(ProgressDispatcher::instance(), SIGNAL(itemCompleted(QString, const SyncFileItem &, const PropagatorJob &)),
|
||||
SLOT(slotItemCompleted(QString, const SyncFileItem &)));
|
||||
connect(ProgressDispatcher::instance(), SIGNAL(syncItemDiscovered(QString, const SyncFileItem &)),
|
||||
this, SLOT(slotSyncItemDiscovered(QString, const SyncFileItem &)));
|
||||
}
|
||||
|
||||
SocketApi::~SocketApi()
|
||||
|
@ -225,48 +221,11 @@ void SocketApi::slotUpdateFolderView(Folder *f)
|
|||
}
|
||||
}
|
||||
|
||||
void SocketApi::slotItemCompleted(const QString &folder, const SyncFileItem &item)
|
||||
void SocketApi::slotFileStatusChanged(const QString& systemFileName, SyncFileStatus fileStatus)
|
||||
{
|
||||
if (_listeners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Folder *f = FolderMan::instance()->folder(folder);
|
||||
if (!f) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto status = f->syncEngine().syncFileStatusTracker().fileStatus(item.destination());
|
||||
const QString path = f->path() + item.destination();
|
||||
broadcastMessage(QLatin1String("STATUS"), path, status.toSocketAPIString());
|
||||
broadcastMessage(QLatin1String("STATUS"), systemFileName, fileStatus.toSocketAPIString());
|
||||
}
|
||||
|
||||
void SocketApi::slotSyncItemDiscovered(const QString &folder, const SyncFileItem &item)
|
||||
{
|
||||
if (_listeners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Folder *f = FolderMan::instance()->folder(folder);
|
||||
if (!f) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString path = f->path() + item.destination();
|
||||
|
||||
// the trailing slash for directories must be appended as the filenames coming in
|
||||
// from the plugins have that too. Otherwise the matching entry item is not found
|
||||
// in the plugin.
|
||||
if( item._type == SyncFileItem::Type::Directory ) {
|
||||
path += QLatin1Char('/');
|
||||
}
|
||||
|
||||
const QString command = QLatin1String("SYNC");
|
||||
broadcastMessage(QLatin1String("STATUS"), path, command);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SocketApi::sendMessage(QIODevice *socket, const QString& message, bool doWait)
|
||||
{
|
||||
DEBUG << "Sending message: " << message;
|
||||
|
|
|
@ -60,12 +60,9 @@ private slots:
|
|||
void slotNewConnection();
|
||||
void onLostConnection();
|
||||
void slotReadSocket();
|
||||
void slotItemCompleted(const QString &, const SyncFileItem &);
|
||||
void slotSyncItemDiscovered(const QString &, const SyncFileItem &);
|
||||
void slotFileStatusChanged(const QString& systemFileName, SyncFileStatus fileStatus);
|
||||
|
||||
private:
|
||||
SyncFileStatus fileStatus(Folder *folder, const QString& systemFileName);
|
||||
|
||||
void sendMessage(QIODevice* socket, const QString& message, bool doWait = false);
|
||||
void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null, bool doWait = false);
|
||||
|
||||
|
|
|
@ -239,8 +239,6 @@ signals:
|
|||
const SyncFileItem & item,
|
||||
const PropagatorJob & job);
|
||||
|
||||
void syncItemDiscovered(const QString &folder, const SyncFileItem & item);
|
||||
|
||||
protected:
|
||||
void setProgressInfo(const QString& folder, const ProgressInfo& progress);
|
||||
|
||||
|
|
|
@ -54,8 +54,10 @@ SyncFileStatusTracker::SyncFileStatusTracker(SyncEngine *syncEngine)
|
|||
connect(syncEngine, SIGNAL(aboutToPropagate(SyncFileItemVector&)),
|
||||
this, SLOT(slotAboutToPropagate(SyncFileItemVector&)));
|
||||
connect(syncEngine, SIGNAL(finished(bool)), SLOT(slotSyncFinished()));
|
||||
connect(syncEngine, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
|
||||
this, SLOT(slotItemCompleted(const SyncFileItem &)));
|
||||
connect(syncEngine, SIGNAL(itemCompleted(const SyncFileItem&, const PropagatorJob&)),
|
||||
this, SLOT(slotItemCompleted(const SyncFileItem&)));
|
||||
connect(syncEngine, SIGNAL(syncItemDiscovered(const SyncFileItem&)),
|
||||
this, SLOT(slotItemDiscovered(const SyncFileItem&)));
|
||||
}
|
||||
|
||||
bool SyncFileStatusTracker::estimateState(QString fn, csync_ftw_type_e t, SyncFileStatus* s)
|
||||
|
@ -225,6 +227,32 @@ void SyncFileStatusTracker::slotItemCompleted(const SyncFileItem &item)
|
|||
if (showErrorInSocketApi(item)) {
|
||||
_stateLastSyncItemsWithErrorNew.insert(item._file);
|
||||
}
|
||||
|
||||
QString systemFileName = _syncEngine->localPath() + item.destination();
|
||||
|
||||
// the trailing slash for directories must be appended as the filenames coming in
|
||||
// from the plugins have that too. Otherwise the matching entry item is not found
|
||||
// in the plugin.
|
||||
if( item._type == SyncFileItem::Type::Directory ) {
|
||||
systemFileName += QLatin1Char('/');
|
||||
}
|
||||
|
||||
auto status = fileStatus(item.destination());
|
||||
emit fileStatusChanged(systemFileName, status);
|
||||
}
|
||||
|
||||
void SyncFileStatusTracker::slotItemDiscovered(const SyncFileItem &item)
|
||||
{
|
||||
QString systemFileName = _syncEngine->localPath() + item.destination();
|
||||
|
||||
// the trailing slash for directories must be appended as the filenames coming in
|
||||
// from the plugins have that too. Otherwise the matching entry item is not found
|
||||
// in the plugin.
|
||||
if( item._type == SyncFileItem::Type::Directory ) {
|
||||
systemFileName += QLatin1Char('/');
|
||||
}
|
||||
|
||||
emit fileStatusChanged(systemFileName, SyncFileStatus(SyncFileStatus::STATUS_EVAL));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,15 +26,20 @@ class SyncEngine;
|
|||
|
||||
class OWNCLOUDSYNC_EXPORT SyncFileStatusTracker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SyncFileStatusTracker(SyncEngine *syncEngine);
|
||||
SyncFileStatus fileStatus(const QString& systemFileName);
|
||||
|
||||
signals:
|
||||
void fileStatusChanged(const QString& systemFileName, SyncFileStatus fileStatus);
|
||||
|
||||
private slots:
|
||||
void slotThreadTreeWalkResult(const SyncFileItemVector& items);
|
||||
void slotAboutToPropagate(SyncFileItemVector& items);
|
||||
void slotSyncFinished();
|
||||
void slotItemCompleted(const SyncFileItem &item);
|
||||
void slotItemDiscovered(const SyncFileItem &item);
|
||||
|
||||
private:
|
||||
bool estimateState(QString fn, csync_ftw_type_e t, SyncFileStatus* s);
|
||||
|
|
Loading…
Reference in a new issue