[Pkg-owncloud-commits] [owncloud-client] 70/115: propagator mkcol: If the server replies with a file-id in the header, use it
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri Aug 29 22:04:02 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 9c98883bea4e20eecde7be59ad6eb00f2d836e18
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Mon Aug 18 20:40:20 2014 +0200
propagator mkcol: If the server replies with a file-id in the header, use it
Newer server will have a file id directly in the file header.
https://github.com/owncloud/core/issues/9000
---
src/mirall/propagatorjobs.cpp | 37 ++++++++++++++++++++++++++++---------
src/mirall/propagatorjobs.h | 1 +
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/src/mirall/propagatorjobs.cpp b/src/mirall/propagatorjobs.cpp
index a94c04a..dad244c 100644
--- a/src/mirall/propagatorjobs.cpp
+++ b/src/mirall/propagatorjobs.cpp
@@ -182,6 +182,19 @@ void PropagateRemoteMkdir::propfind_results(void *userdata,
}
}
+/*
+ * Called after the headers have been recieved, try to extract the fileId
+ */
+void PropagateRemoteMkdir::post_headers(ne_request* req, void* userdata, const ne_status* )
+{
+ const char *header = ne_get_response_header(req, "OC-FileId");
+ if( header ) {
+ qDebug() << "MKCOL: " << static_cast<PropagateRemoteMkdir*>(userdata)->_item._file << " FileID from header:" << header;
+ static_cast<PropagateRemoteMkdir*>(userdata)->_item._fileId = header;
+ }
+}
+
+
void PropagateRemoteMkdir::start()
{
if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
@@ -190,8 +203,13 @@ void PropagateRemoteMkdir::start()
QScopedPointer<char, QScopedPointerPodDeleter> uri(
ne_path_escape((_propagator->_remoteDir + _item._file).toUtf8()));
+ ne_hook_post_headers(_propagator->_session, post_headers, this);
+
int rc = ne_mkcol(_propagator->_session, uri.data());
+ ne_unhook_post_headers(_propagator->_session, post_headers, this);
+
+
/* Special for mkcol: it returns 405 if the directory already exists.
* Ignore that error */
// Wed, 15 Nov 1995 06:25:24 GMT
@@ -202,15 +220,16 @@ void PropagateRemoteMkdir::start()
return;
}
- // Get the fileid
- // This is required so that wa can detect moves even if the folder is renamed on the server
- // while files are still uploading
- // TODO: Now we have to do a propfind because the server does not give the file id in the request
- // https://github.com/owncloud/core/issues/9000
-
- ne_propfind_handler *hdl = ne_propfind_create(_propagator->_session, uri.data(), 0);
- ne_propfind_named(hdl, ls_props, propfind_results, this);
- ne_propfind_destroy(hdl);
+ if (_item._fileId.isEmpty()) {
+ // Owncloud 7.0.0 and before did not have a header with the file id.
+ // (https://github.com/owncloud/core/issues/9000)
+ // So we must get the file id using a PROPFIND
+ // This is required so that wa can detect moves even if the folder is renamed on the server
+ // while files are still uploading
+ ne_propfind_handler *hdl = ne_propfind_create(_propagator->_session, uri.data(), 0);
+ ne_propfind_named(hdl, ls_props, propfind_results, this);
+ ne_propfind_destroy(hdl);
+ }
done(SyncFileItem::Success);
}
diff --git a/src/mirall/propagatorjobs.h b/src/mirall/propagatorjobs.h
index df7a5e4..6e8e30c 100644
--- a/src/mirall/propagatorjobs.h
+++ b/src/mirall/propagatorjobs.h
@@ -96,6 +96,7 @@ public:
void start() Q_DECL_OVERRIDE;
private:
static void propfind_results(void *userdata, const ne_uri *uri, const ne_prop_result_set *set);
+ static void post_headers(ne_request *req, void *userdata, const ne_status *status);
friend class PropagateDirectory; // So it can access the _item;
};
class PropagateLocalRename : public PropagateItemJob {
--
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