Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsync: use the new webdav url if the server reports it #5332

Merged
merged 1 commit into from
Nov 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ Account::~Account()

QString Account::davPath() const
{
if (capabilities().chunkingNg()) {
Copy link
Contributor

@mrow4a mrow4a Nov 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this "if" here? I might want to use it for bundling also. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chunking ng is in >=9.2..

Copy link
Contributor

@mrow4a mrow4a Nov 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: oh sorry, code in github wrapped and have not seen the rest. Of course it is good.

Copy link
Contributor

@mrow4a mrow4a Nov 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But been mostly thinking about creating just separate function instead of "if", but in this case it makes no sense. It is all good. For bundling I will just need to work-around this. Because I would need that String (the same) anyways, but only for uploaded files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because both chunkingng and the new dav url need to be enabled at the same time! (the old chunking don't work with the new url, and the new chunking don't work with the old one)

Maybe the capability should be renamed "useNewDavPath()"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"filesDavPath" is ok with me.

// The chunking-ng means the server prefer to use the new webdav URL
return QLatin1String("/remote.php/dav/files/") + davUser() + QLatin1Char('/');
}

// make sure to have a trailing slash
if( !_davPath.endsWith('/') ) {
QString dp(_davPath);
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ QByteArray Capabilities::uploadChecksumType() const

bool Capabilities::chunkingNg() const
{
static const auto chunkng = qgetenv("OWNCLOUD_CHUNKING_NG");
if (chunkng == "0") return false;
if (chunkng == "1") return true;
return _capabilities["dav"].toMap()["chunking"].toByteArray() >= "1.0";
}

Expand Down
4 changes: 1 addition & 3 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ PropagateItemJob* OwncloudPropagator::createJob(const SyncFileItemPtr &item) {
return job;
} else {
PropagateUploadFileCommon *job = 0;
static const auto chunkng = qgetenv("OWNCLOUD_CHUNKING_NG");
if (item->_size > chunkSize()
&& (account()->capabilities().chunkingNg() || chunkng == "1") && chunkng != "0") {
if (item->_size > chunkSize() && account()->capabilities().chunkingNg()) {
job = new PropagateUploadFileNG(this, item);
} else {
job = new PropagateUploadFileV1(this, item);
Expand Down
6 changes: 2 additions & 4 deletions src/libsync/propagateuploadng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,8 @@ void PropagateUploadFileNG::startNextChunk()
Q_ASSERT(_jobs.isEmpty()); // There should be no running job anymore
_finished = true;
// Finish with a MOVE
QString destination = _propagator->account()->url().path()
+ QLatin1String("/remote.php/dav/files/") + _propagator->account()->davUser()
+ _propagator->_remoteFolder + _item->_file;

QString destination = QDir::cleanPath(_propagator->account()->url().path() + QLatin1Char('/')
+ _propagator->account()->davPath() + _propagator->_remoteFolder + _item->_file);
auto headers = PropagateUploadFileCommon::headers();

// "If-Match applies to the source, but we are interested in comparing the etag of the destination
Expand Down