[Pkg-owncloud-commits] [owncloud-client] 49/333: PropagateRemoteRename is not a legacy job
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:32 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 58bda69f8b09e84faf3048e37ae05a6ad1f0020a
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue Feb 18 13:52:40 2014 +0100
PropagateRemoteRename is not a legacy job
move it back to propagatorjobs.cpp
---
src/mirall/propagator_legacy.cpp | 151 --------------------------------------
src/mirall/propagatorjobs.cpp | 152 +++++++++++++++++++++++++++++++++++++++
2 files changed, 152 insertions(+), 151 deletions(-)
diff --git a/src/mirall/propagator_legacy.cpp b/src/mirall/propagator_legacy.cpp
index 8c9c236..4106db0 100644
--- a/src/mirall/propagator_legacy.cpp
+++ b/src/mirall/propagator_legacy.cpp
@@ -638,155 +638,4 @@ void PropagateDownloadFileLegacy::start()
}
-void PropagateLocalRename::start()
-{
- if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
- return;
-
- // if the file is a file underneath a moved dir, the _item.file is equal
- // to _item.renameTarget and the file is not moved as a result.
- if (_item._file != _item._renameTarget) {
- emit progress(Progress::StartRename, _item, 0, _item._size);
- qDebug() << "MOVE " << _propagator->_localDir + _item._file << " => " << _propagator->_localDir + _item._renameTarget;
- QFile::rename(_propagator->_localDir + _item._file, _propagator->_localDir + _item._renameTarget);
- emit progress(Progress::EndRename, _item, _item._size, _item._size);
- }
-
- _item._instruction = CSYNC_INSTRUCTION_DELETED;
- _propagator->_journal->deleteFileRecord(_item._originalFile);
-
- // store the rename file name in the item.
- _item._file = _item._renameTarget;
-
- SyncJournalFileRecord record(_item, _propagator->_localDir + _item._renameTarget);
- record._path = _item._renameTarget;
-
- if (!_item._isDirectory) { // Directory are saved at the end
- _propagator->_journal->setFileRecord(record);
- }
- _propagator->_journal->commit("localRename");
-
-
- done(SyncFileItem::Success);
-}
-
-void PropagateRemoteRename::start()
-{
- if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
- return;
-
- if (_item._file == _item._renameTarget) {
- if (!_item._isDirectory) {
- // The parents has been renamed already so there is nothing more to do.
- // But we still need to fetch the new ETAG
- // FIXME maybe do a recusrsive propfind after having moved the parent.
- // Note: we also update the mtime because the server do not keep the mtime when moving files
- QScopedPointer<char, QScopedPointerPodDeleter> uri2(
- ne_path_escape((_propagator->_remoteDir + _item._renameTarget).toUtf8()));
- if (!updateMTimeAndETag(uri2.data(), _item._modtime))
- return;
- }
- } else if (_item._file == QLatin1String("Shared") ) {
- // Check if it is the toplevel Shared folder and do not propagate it.
- if( QFile::rename( _propagator->_localDir + _item._renameTarget, _propagator->_localDir + QLatin1String("Shared")) ) {
- done(SyncFileItem::NormalError, tr("This folder must not be renamed. It is renamed back to its original name."));
- } else {
- done(SyncFileItem::NormalError, tr("This folder must not be renamed. Please name it back to Shared."));
- }
- return;
- } else {
- emit progress(Progress::StartRename, _item, 0, _item._size);
-
- QScopedPointer<char, QScopedPointerPodDeleter> uri1(ne_path_escape((_propagator->_remoteDir + _item._file).toUtf8()));
- QScopedPointer<char, QScopedPointerPodDeleter> uri2(ne_path_escape((_propagator->_remoteDir + _item._renameTarget).toUtf8()));
- qDebug() << "MOVE on Server: " << uri1.data() << "->" << uri2.data();
-
- int rc = ne_move(_propagator->_session, 1, uri1.data(), uri2.data());
-
- if( checkForProblemsWithShared()) {
- return;
- }
-
- if (updateErrorFromSession(rc)) {
- return;
- }
-
- if (!updateMTimeAndETag(uri2.data(), _item._modtime))
- return;
- emit progress(Progress::EndRename, _item, _item._size, _item._size);
- }
-
- _propagator->_journal->deleteFileRecord(_item._originalFile);
- SyncJournalFileRecord record(_item, _propagator->_localDir + _item._renameTarget);
- record._path = _item._renameTarget;
-
- _propagator->_journal->setFileRecord(record);
- _propagator->_journal->commit("Remote Rename");
- done(SyncFileItem::Success);
-}
-
-bool PropagateNeonJob::updateErrorFromSession(int neon_code, ne_request* req, int ignoreHttpCode)
-{
- if( neon_code != NE_OK ) {
- qDebug("Neon error code was %d", neon_code);
- }
-
- QString errorString;
- int httpStatusCode = 0;
-
- switch(neon_code) {
- case NE_OK: /* Success, but still the possiblity of problems */
- if( req ) {
- const ne_status *status = ne_get_status(req);
-
- if (status) {
- if ( status->klass == 2 || status->code == ignoreHttpCode) {
- // Everything is ok, no error.
- return false;
- }
- errorString = QString::fromUtf8( status->reason_phrase );
- httpStatusCode = status->code;
- _item._httpErrorCode = httpStatusCode;
- }
- } else {
- errorString = QString::fromUtf8(ne_get_error(_propagator->_session));
- httpStatusCode = errorString.mid(0, errorString.indexOf(QChar(' '))).toInt();
- _item._httpErrorCode = httpStatusCode;
- if ((httpStatusCode >= 200 && httpStatusCode < 300)
- || (httpStatusCode != 0 && httpStatusCode == ignoreHttpCode)) {
- // No error
- return false;
- }
- }
- // FIXME: classify the error
- done (SyncFileItem::NormalError, errorString);
- return true;
- case NE_ERROR: /* Generic error; use ne_get_error(session) for message */
- errorString = QString::fromUtf8(ne_get_error(_propagator->_session));
- // Check if we don't need to ignore that error.
- httpStatusCode = errorString.mid(0, errorString.indexOf(QChar(' '))).toInt();
- _item._httpErrorCode = httpStatusCode;
- qDebug() << Q_FUNC_INFO << "NE_ERROR" << errorString << httpStatusCode << ignoreHttpCode;
- if (ignoreHttpCode && httpStatusCode == ignoreHttpCode)
- return false;
-
- done(SyncFileItem::NormalError, errorString);
- return true;
- case NE_LOOKUP: /* Server or proxy hostname lookup failed */
- case NE_AUTH: /* User authentication failed on server */
- case NE_PROXYAUTH: /* User authentication failed on proxy */
- case NE_CONNECT: /* Could not connect to server */
- case NE_TIMEOUT: /* Connection timed out */
- done(SyncFileItem::FatalError, QString::fromUtf8(ne_get_error(_propagator->_session)));
- return true;
- case NE_FAILED: /* The precondition failed */
- case NE_RETRY: /* Retry request (ne_end_request ONLY) */
- case NE_REDIRECT: /* See ne_redirect.h */
- default:
- done(SyncFileItem::SoftError, QString::fromUtf8(ne_get_error(_propagator->_session)));
- return true;
- }
- return false;
-}
-
}
diff --git a/src/mirall/propagatorjobs.cpp b/src/mirall/propagatorjobs.cpp
index 26b6c49..035ee91 100644
--- a/src/mirall/propagatorjobs.cpp
+++ b/src/mirall/propagatorjobs.cpp
@@ -205,4 +205,156 @@ void PropagateRemoteMkdir::start()
}
+void PropagateLocalRename::start()
+{
+ if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
+ return;
+
+ // if the file is a file underneath a moved dir, the _item.file is equal
+ // to _item.renameTarget and the file is not moved as a result.
+ if (_item._file != _item._renameTarget) {
+ emit progress(Progress::StartRename, _item, 0, _item._size);
+ qDebug() << "MOVE " << _propagator->_localDir + _item._file << " => " << _propagator->_localDir + _item._renameTarget;
+ QFile::rename(_propagator->_localDir + _item._file, _propagator->_localDir + _item._renameTarget);
+ emit progress(Progress::EndRename, _item, _item._size, _item._size);
+ }
+
+ _item._instruction = CSYNC_INSTRUCTION_DELETED;
+ _propagator->_journal->deleteFileRecord(_item._originalFile);
+
+ // store the rename file name in the item.
+ _item._file = _item._renameTarget;
+
+ SyncJournalFileRecord record(_item, _propagator->_localDir + _item._renameTarget);
+ record._path = _item._renameTarget;
+
+ if (!_item._isDirectory) { // Directory are saved at the end
+ _propagator->_journal->setFileRecord(record);
+ }
+ _propagator->_journal->commit("localRename");
+
+
+ done(SyncFileItem::Success);
+}
+
+void PropagateRemoteRename::start()
+{
+ if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
+ return;
+
+ if (_item._file == _item._renameTarget) {
+ if (!_item._isDirectory) {
+ // The parents has been renamed already so there is nothing more to do.
+ // But we still need to fetch the new ETAG
+ // FIXME maybe do a recusrsive propfind after having moved the parent.
+ // Note: we also update the mtime because the server do not keep the mtime when moving files
+ QScopedPointer<char, QScopedPointerPodDeleter> uri2(
+ ne_path_escape((_propagator->_remoteDir + _item._renameTarget).toUtf8()));
+ if (!updateMTimeAndETag(uri2.data(), _item._modtime))
+ return;
+ }
+ } else if (_item._file == QLatin1String("Shared") ) {
+ // Check if it is the toplevel Shared folder and do not propagate it.
+ if( QFile::rename( _propagator->_localDir + _item._renameTarget, _propagator->_localDir + QLatin1String("Shared")) ) {
+ done(SyncFileItem::NormalError, tr("This folder must not be renamed. It is renamed back to its original name."));
+ } else {
+ done(SyncFileItem::NormalError, tr("This folder must not be renamed. Please name it back to Shared."));
+ }
+ return;
+ } else {
+ emit progress(Progress::StartRename, _item, 0, _item._size);
+
+ QScopedPointer<char, QScopedPointerPodDeleter> uri1(ne_path_escape((_propagator->_remoteDir + _item._file).toUtf8()));
+ QScopedPointer<char, QScopedPointerPodDeleter> uri2(ne_path_escape((_propagator->_remoteDir + _item._renameTarget).toUtf8()));
+ qDebug() << "MOVE on Server: " << uri1.data() << "->" << uri2.data();
+
+ int rc = ne_move(_propagator->_session, 1, uri1.data(), uri2.data());
+
+ if( checkForProblemsWithShared()) {
+ return;
+ }
+
+ if (updateErrorFromSession(rc)) {
+ return;
+ }
+
+ if (!updateMTimeAndETag(uri2.data(), _item._modtime))
+ return;
+ emit progress(Progress::EndRename, _item, _item._size, _item._size);
+ }
+
+ _propagator->_journal->deleteFileRecord(_item._originalFile);
+ SyncJournalFileRecord record(_item, _propagator->_localDir + _item._renameTarget);
+ record._path = _item._renameTarget;
+
+ _propagator->_journal->setFileRecord(record);
+ _propagator->_journal->commit("Remote Rename");
+ done(SyncFileItem::Success);
+}
+
+bool PropagateNeonJob::updateErrorFromSession(int neon_code, ne_request* req, int ignoreHttpCode)
+{
+ if( neon_code != NE_OK ) {
+ qDebug("Neon error code was %d", neon_code);
+ }
+
+ QString errorString;
+ int httpStatusCode = 0;
+
+ switch(neon_code) {
+ case NE_OK: /* Success, but still the possiblity of problems */
+ if( req ) {
+ const ne_status *status = ne_get_status(req);
+
+ if (status) {
+ if ( status->klass == 2 || status->code == ignoreHttpCode) {
+ // Everything is ok, no error.
+ return false;
+ }
+ errorString = QString::fromUtf8( status->reason_phrase );
+ httpStatusCode = status->code;
+ _item._httpErrorCode = httpStatusCode;
+ }
+ } else {
+ errorString = QString::fromUtf8(ne_get_error(_propagator->_session));
+ httpStatusCode = errorString.mid(0, errorString.indexOf(QChar(' '))).toInt();
+ _item._httpErrorCode = httpStatusCode;
+ if ((httpStatusCode >= 200 && httpStatusCode < 300)
+ || (httpStatusCode != 0 && httpStatusCode == ignoreHttpCode)) {
+ // No error
+ return false;
+ }
+ }
+ // FIXME: classify the error
+ done (SyncFileItem::NormalError, errorString);
+ return true;
+ case NE_ERROR: /* Generic error; use ne_get_error(session) for message */
+ errorString = QString::fromUtf8(ne_get_error(_propagator->_session));
+ // Check if we don't need to ignore that error.
+ httpStatusCode = errorString.mid(0, errorString.indexOf(QChar(' '))).toInt();
+ _item._httpErrorCode = httpStatusCode;
+ qDebug() << Q_FUNC_INFO << "NE_ERROR" << errorString << httpStatusCode << ignoreHttpCode;
+ if (ignoreHttpCode && httpStatusCode == ignoreHttpCode)
+ return false;
+
+ done(SyncFileItem::NormalError, errorString);
+ return true;
+ case NE_LOOKUP: /* Server or proxy hostname lookup failed */
+ case NE_AUTH: /* User authentication failed on server */
+ case NE_PROXYAUTH: /* User authentication failed on proxy */
+ case NE_CONNECT: /* Could not connect to server */
+ case NE_TIMEOUT: /* Connection timed out */
+ done(SyncFileItem::FatalError, QString::fromUtf8(ne_get_error(_propagator->_session)));
+ return true;
+ case NE_FAILED: /* The precondition failed */
+ case NE_RETRY: /* Retry request (ne_end_request ONLY) */
+ case NE_REDIRECT: /* See ne_redirect.h */
+ default:
+ done(SyncFileItem::SoftError, QString::fromUtf8(ne_get_error(_propagator->_session)));
+ return true;
+ }
+ return false;
+}
+
+
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list