Skip to content

Commit

Permalink
Discovery: Report root etag from engine to folder
Browse files Browse the repository at this point in the history
For #2352
  • Loading branch information
guruz committed Jan 23, 2015
1 parent f284786 commit 3885d5d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ endif()
# find_package(Qt4 4.7.0 COMPONENTS QtDBus REQUIRED )
#endif()


set(NO_NEON_REQUIRED FALSE)
if(HAVE_QT5)
message(STATUS "Using Qt ${Qt5Core_VERSION_MAJOR}.${Qt5Core_VERSION_MINOR}.x")
if (${Qt5Core_VERSION_MAJOR} EQUAL "5")
Expand Down
8 changes: 8 additions & 0 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ void Folder::etagRetreived(const QString& etag)
}
}

void Folder::etagRetreivedFromSyncEngine(const QString& etag)
{
qDebug() << "Root etag from during sync:" << etag;
_lastEtag = etag;
}


void Folder::bubbleUpSyncResult()
{
// count new, removed and updated items
Expand Down Expand Up @@ -780,6 +787,7 @@ void Folder::startSync(const QStringList &pathList)
qRegisterMetaType<SyncFileItemVector>("SyncFileItemVector");
qRegisterMetaType<SyncFileItem::Direction>("SyncFileItem::Direction");

connect(_engine.data(), SIGNAL(rootEtag(QString)), this, SLOT(etagRetreivedFromSyncEngine(QString)));
connect( _engine.data(), SIGNAL(treeWalkResult(const SyncFileItemVector&)),
this, SLOT(slotThreadTreeWalkResult(const SyncFileItemVector&)), Qt::QueuedConnection);
connect( _engine.data(), SIGNAL(aboutToPropagate(const SyncFileItemVector&)),
Expand Down
1 change: 1 addition & 0 deletions src/gui/folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ private slots:

void slotRunEtagJob();
void etagRetreived(const QString &);
void etagRetreivedFromSyncEngine(const QString &);

void slotAboutToPropagate(const SyncFileItemVector& );
void slotThreadTreeWalkResult(const SyncFileItemVector& ); // after sync is done
Expand Down
4 changes: 4 additions & 0 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file,QMap
if (map.contains("permissions")) {
emit firstDirectoryPermissions(map.value("permissions"));
}
if (map.contains("getetag")) {
emit firstDirectoryEtag(map.value("getetag"));
}
} else {
// Remove /remote.php/webdav/folder/ from /remote.php/webdav/folder/subfile.txt
file.remove(0, _lsColJob->reply()->request().url().path().length());
Expand Down Expand Up @@ -324,6 +327,7 @@ void DiscoveryMainThread::doOpendirSlot(QString subPath, DiscoveryDirectoryResul
this, SLOT(singleDirectoryJobResultSlot(QLinkedList<csync_vio_file_stat_t*>)));
QObject::connect(_singleDirJob, SIGNAL(finishedWithError(int,QString)),
this, SLOT(singleDirectoryJobFinishedWithErrorSlot(int,QString)));
QObject::connect(_singleDirJob, SIGNAL(firstDirectoryEtag(QString)), this, SIGNAL(rootEtag(QString)));
_singleDirJob->start();
}

Expand Down
7 changes: 5 additions & 2 deletions src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class DiscoverySingleDirectoryJob : public QObject {
void abort();
// This is not actually a network job, it is just a job
signals:
void firstDirectoryPermissions(QString);
void firstDirectoryPermissions(const QString &);
void firstDirectoryEtag(const QString &);
void finishedWithResult(QLinkedList<csync_vio_file_stat_t*>);
void finishedWithError(int csyncErrnoCode, QString msg);
void finishedWithError(int csyncErrnoCode, QString &msg);
private slots:
void directoryListingIteratedSlot(QString,QMap<QString,QString>);
void lsJobFinishedWithoutErrorSlot();
Expand Down Expand Up @@ -110,6 +111,8 @@ public slots:
void singleDirectoryJobResultSlot(QLinkedList<csync_vio_file_stat_t*>);
void singleDirectoryJobFinishedWithErrorSlot(int csyncErrnoCode, QString msg);
void singleDirectoryJobFirstDirectoryPermissionsSlot(QString);
signals:
void rootEtag(QString);
public:
void setupHooks(DiscoveryJob* discoveryJob, const QString &pathPrefix);
};
Expand Down
4 changes: 3 additions & 1 deletion src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ void RequestEtagJob::start()
/* For the root directory, we need to query the etags of all the sub directories
* because, at the time I am writing this comment (Owncloud 5.0.9), the etag of the
* root directory is not updated when the sub directories changes */
req.setRawHeader("Depth", "1");
//req.setRawHeader("Depth", "1");
//This should be fixed since oC6 https://github.com/owncloud/core/issues/5255
req.setRawHeader("Depth", "0");
} else {
req.setRawHeader("Depth", "0");
}
Expand Down
9 changes: 9 additions & 0 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ void SyncEngine::startSync()
_discoveryMainThread = new DiscoveryMainThread(account());
_discoveryMainThread->setParent(this);
connect(this, SIGNAL(finished()), _discoveryMainThread, SLOT(deleteLater()));
connect(_discoveryMainThread, SIGNAL(rootEtag(QString)), this, SLOT(slotRootEtagReceived(QString)));


DiscoveryJob *discoveryJob = new DiscoveryJob(_csync_ctx);
Expand All @@ -624,6 +625,14 @@ void SyncEngine::startSync()
QMetaObject::invokeMethod(discoveryJob, "start", Qt::QueuedConnection);
}

void SyncEngine::slotRootEtagReceived(QString e) {
qDebug() << Q_FUNC_INFO << e;
if (_remoteRootEtag.isEmpty()) {
_remoteRootEtag = e;
emit rootEtag(_remoteRootEtag);
}
}

void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
{
// To clean the progress info
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/syncengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject
void csyncUnavailable();

// During update, before reconcile
void rootEtag(QString);
void folderDiscovered(bool local, QString folderUrl);

// before actual syncing (after update+reconcile) for each item
Expand All @@ -108,6 +109,7 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject
void aboutToRemoveAllFiles(SyncFileItem::Direction direction, bool *cancel);

private slots:
void slotRootEtagReceived(QString);
void slotJobCompleted(const SyncFileItem& item);
void slotFinished();
void slotProgress(const SyncFileItem& item, quint64 curent);
Expand Down Expand Up @@ -150,6 +152,7 @@ private slots:
QString _localPath;
QString _remoteUrl;
QString _remotePath;
QString _remoteRootEtag;
SyncJournalDb *_journal;
QPointer<DiscoveryMainThread> _discoveryMainThread;
QSharedPointer <OwncloudPropagator> _propagator;
Expand Down

0 comments on commit 3885d5d

Please sign in to comment.