ASSERT(!_isError);
return _result;
}
+
T operator*() &&
{
ASSERT(!_isError);
return &_result;
}
+ const T &get() const
+ {
+ ASSERT(!_isError)
+ return _result;
+ }
+
const Error &error() const &
{
ASSERT(_isError);
// The _requestEtagJob is auto deleting itself on finish. Our guard pointer _requestEtagJob will then be null.
}
-void Folder::etagRetrieved(const QString &etag, const QDateTime &tp)
+void Folder::etagRetrieved(const QByteArray &etag, const QDateTime &tp)
{
// re-enable sync if it was disabled because network was down
FolderMan::instance()->setSyncEnabled(true);
_accountState->tagLastSuccessfullETagRequest(tp);
}
-void Folder::etagRetrievedFromSyncEngine(const QString &etag, const QDateTime &time)
+void Folder::etagRetrievedFromSyncEngine(const QByteArray &etag, const QDateTime &time)
{
qCInfo(lcFolder) << "Root etag from during sync:" << etag;
accountState()->tagLastSuccessfullETagRequest(time);
void slotItemCompleted(const SyncFileItemPtr &);
void slotRunEtagJob();
- void etagRetrieved(const QString &, const QDateTime &tp);
- void etagRetrievedFromSyncEngine(const QString &, const QDateTime &time);
+ void etagRetrieved(const QByteArray &, const QDateTime &tp);
+ void etagRetrievedFromSyncEngine(const QByteArray &, const QDateTime &time);
void slotEmitFinishedDelayed();
SyncResult _syncResult;
QScopedPointer<SyncEngine> _engine;
QPointer<RequestEtagJob> _requestEtagJob;
- QString _lastEtag;
+ QByteArray _lastEtag;
QElapsedTimer _timeSinceLastSyncDone;
QElapsedTimer _timeSinceLastSyncStart;
QElapsedTimer _timeSinceLastFullLocalDiscovery;
}
return ParentNotChanged;
}();
-
+
processFileAnalyzeLocalInfo(item, path, localEntry, serverEntry, dbEntry, serverQueryMode);
return;
}
item->_modtime = serverEntry.modtime;
item->_size = serverEntry.size;
- auto postProcessServerNew = [=] () {
- auto tmp_path = path;
+ auto postProcessServerNew = [=]() mutable {
if (item->isDirectory()) {
_pendingAsyncJobs++;
- _discoveryData->checkSelectiveSyncNewFolder(tmp_path._server, serverEntry.remotePerm,
+ _discoveryData->checkSelectiveSyncNewFolder(path._server, serverEntry.remotePerm,
[=](bool result) {
--_pendingAsyncJobs;
if (!result) {
- processFileAnalyzeLocalInfo(item, tmp_path, localEntry, serverEntry, dbEntry, _queryServer);
+ processFileAnalyzeLocalInfo(item, path, localEntry, serverEntry, dbEntry, _queryServer);
}
QTimer::singleShot(0, _discoveryData, &DiscoveryPhase::scheduleMoreJobs);
});
&& !FileSystem::isExcludeFile(item->_file)) {
item->_type = ItemTypeVirtualFile;
if (isVfsWithSuffix())
- addVirtualFileSuffix(tmp_path._original);
+ addVirtualFileSuffix(path._original);
}
if (opts._vfs->mode() != Vfs::Off && !item->_encryptedFileName.isEmpty()) {
// another scenario - we are syncing a file which is on disk but not in the database (database was removed or file was not written there yet)
item->_size = serverEntry.size - Constants::e2EeTagSize;
}
- processFileAnalyzeLocalInfo(item, tmp_path, localEntry, serverEntry, dbEntry, _queryServer);
+ processFileAnalyzeLocalInfo(item, path, localEntry, serverEntry, dbEntry, _queryServer);
};
// Potential NEW/NEW conflict is handled in AnalyzeLocal
// we need to make a request to the server to know that the original file is deleted on the server
_pendingAsyncJobs++;
auto job = new RequestEtagJob(_discoveryData->_account, originalPath, this);
- connect(job, &RequestEtagJob::finishedWithResult, this, [=](const HttpResult<QString> &etag) {
- auto tmp_path = path;
+ connect(job, &RequestEtagJob::finishedWithResult, this, [=](const HttpResult<QByteArray> &etag) mutable {
_pendingAsyncJobs--;
QTimer::singleShot(0, _discoveryData, &DiscoveryPhase::scheduleMoreJobs);
if (etag || etag.error().code != 404 ||
// In case the deleted item was discovered in parallel
_discoveryData->findAndCancelDeletedJob(originalPath);
- postProcessRename(tmp_path);
- processFileFinalize(item, tmp_path, item->isDirectory(), item->_instruction == CSYNC_INSTRUCTION_RENAME ? NormalQuery : ParentDontExist, _queryServer);
+ postProcessRename(path);
+ processFileFinalize(item, path, item->isDirectory(), item->_instruction == CSYNC_INSTRUCTION_RENAME ? NormalQuery : ParentDontExist, _queryServer);
});
job->start();
done = true; // Ideally, if the origin still exist on the server, we should continue searching... but that'd be difficult
if (base.isVirtualFile() && isVfsWithSuffix())
chopVirtualFileSuffix(serverOriginalPath);
auto job = new RequestEtagJob(_discoveryData->_account, serverOriginalPath, this);
- connect(job, &RequestEtagJob::finishedWithResult, this, [=](const HttpResult<QString> &etag) mutable {
- if (!etag || (*etag != base._etag && !item->isDirectory()) || _discoveryData->isRenamed(originalPath)) {
+ connect(job, &RequestEtagJob::finishedWithResult, this, [=](const HttpResult<QByteArray> &etag) mutable {
+ if (!etag || (etag.get() != base._etag && !item->isDirectory()) || _discoveryData->isRenamed(originalPath)) {
qCInfo(lcDisco) << "Can't rename because the etag has changed or the directory is gone" << originalPath;
// Can't be a rename, leave it as a new.
postProcessLocalNew();
// In case the deleted item was discovered in parallel
_discoveryData->findAndCancelDeletedJob(originalPath);
processRename(path);
- recurseQueryServer = *etag == base._etag ? ParentNotChanged : NormalQuery;
+ recurseQueryServer = etag.get() == base._etag ? ParentNotChanged : NormalQuery;
}
processFileFinalize(item, path, item->isDirectory(), NormalQuery, recurseQueryServer);
_pendingAsyncJobs--;
signals:
void finished();
// The root etag of this directory was fetched
- void etag(const QString &, const QDateTime &time);
+ void etag(const QByteArray &, const QDateTime &time);
};
}
//This works in concerto with the RequestEtagJob and the Folder object to check if the remote folder changed.
if (map.contains("getetag")) {
if (_firstEtag.isEmpty()) {
- _firstEtag = parseEtag(map.value("getetag").toUtf8()); // for directory itself
+ _firstEtag = parseEtag(map.value(QStringLiteral("getetag")).toUtf8()); // for directory itself
}
}
}
// This is not actually a network job, it is just a job
signals:
void firstDirectoryPermissions(RemotePermissions);
- void etag(const QString &, const QDateTime &time);
+ void etag(const QByteArray &, const QDateTime &time);
void finished(const HttpResult<QVector<RemoteInfo>> &result);
private slots:
private:
QVector<RemoteInfo> _results;
QString _subPath;
- QString _firstEtag;
+ QByteArray _firstEtag;
QByteArray _fileId;
AccountPtr _account;
// The first result is for the directory itself and need to be ignored.
if (httpCode == 207) {
// Parse DAV response
QXmlStreamReader reader(reply());
- reader.addExtraNamespaceDeclaration(QXmlStreamNamespaceDeclaration("d", "DAV:"));
- QString etag;
+ reader.addExtraNamespaceDeclaration(QXmlStreamNamespaceDeclaration(QStringLiteral("d"), QStringLiteral("DAV:")));
+ QByteArray etag;
while (!reader.atEnd()) {
QXmlStreamReader::TokenType type = reader.readNext();
if (type == QXmlStreamReader::StartElement && reader.namespaceUri() == QLatin1String("DAV:")) {
auto etagText = reader.readElementText();
auto parsedTag = parseEtag(etagText.toUtf8());
if (!parsedTag.isEmpty()) {
- etag += QString::fromUtf8(parsedTag);
+ etag += parsedTag;
} else {
- etag += etagText;
+ etag += etagText.toUtf8();
}
}
}
void start() override;
signals:
- void etagRetrieved(const QString &etag, const QDateTime &time);
- void finishedWithResult(const HttpResult<QString> &etag);
+ void etagRetrieved(const QByteArray &etag, const QDateTime &time);
+ void finishedWithResult(const HttpResult<QByteArray> &etag);
private slots:
bool finished() override;
* @param statusCode - the OCS status code: 100 (!) for success
*/
void etagResponseHeaderReceived(const QByteArray &value, int statusCode);
-
+
/**
* @brief desktopNotificationStatusReceived - signal to report if notifications are allowed
- * @param status - set desktop notifications allowed status
+ * @param status - set desktop notifications allowed status
*/
void allowDesktopNotificationsChanged(bool isAllowed);
emit transmissionProgress(*_progressInfo);
}
-void SyncEngine::slotRootEtagReceived(const QString &e, const QDateTime &time)
+void SyncEngine::slotRootEtagReceived(const QByteArray &e, const QDateTime &time)
{
if (_remoteRootEtag.isEmpty()) {
qCDebug(lcEngine) << "Root etag:" << e;
signals:
// During update, before reconcile
- void rootEtag(const QString &, const QDateTime &);
+ void rootEtag(const QByteArray &, const QDateTime &);
// after the above signals. with the items that actually need propagating
void aboutToPropagate(SyncFileItemVector &);
private slots:
void slotFolderDiscovered(bool local, const QString &folder);
- void slotRootEtagReceived(const QString &, const QDateTime &time);
+ void slotRootEtagReceived(const QByteArray &, const QDateTime &time);
/** When the discovery phase discovers an item */
void slotItemDiscovered(const SyncFileItemPtr &item);
bool _syncRunning;
QString _localPath;
QString _remotePath;
- QString _remoteRootEtag;
+ QByteArray _remoteRootEtag;
SyncJournalDb *_journal;
QScopedPointer<DiscoveryPhase> _discoveryPhase;
QSharedPointer<OwncloudPropagator> _propagator;