зеркало из https://github.com/nextcloud/desktop.git
Merge pull request #6133 from nextcloud/bugfix/chunk-v2-dest-header
Fix chunk v2 destination header
This commit is contained in:
Коммит
4ca69f6c44
|
@ -729,4 +729,11 @@ QString Utility::trailingSlashPath(const QString &path)
|
|||
return path.endsWith(slash) ? path : QString(path + slash);
|
||||
}
|
||||
|
||||
QString Utility::noLeadingSlashPath(const QString &path)
|
||||
{
|
||||
static const auto slash = QLatin1Char('/');
|
||||
return path.startsWith(slash) ? path.mid(1) : path;
|
||||
}
|
||||
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -256,6 +256,7 @@ namespace Utility {
|
|||
OCSYNC_EXPORT void registerUriHandlerForLocalEditing();
|
||||
|
||||
OCSYNC_EXPORT QString trailingSlashPath(const QString &path);
|
||||
OCSYNC_EXPORT QString noLeadingSlashPath(const QString &path);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
OCSYNC_EXPORT bool registryKeyExists(HKEY hRootKey, const QString &subKey);
|
||||
|
|
|
@ -410,6 +410,7 @@ private:
|
|||
|
||||
[[nodiscard]] QUrl chunkUploadFolderUrl() const;
|
||||
[[nodiscard]] QUrl chunkUrl(const int chunk) const;
|
||||
[[nodiscard]] QByteArray destinationHeader() const;
|
||||
|
||||
void startNewUpload();
|
||||
void startNextChunk();
|
||||
|
|
|
@ -85,6 +85,14 @@ QUrl PropagateUploadFileNG::chunkUrl(const int chunk) const
|
|||
|
||||
*/
|
||||
|
||||
QByteArray PropagateUploadFileNG::destinationHeader() const
|
||||
{
|
||||
const auto davUrl = Utility::trailingSlashPath(propagator()->account()->davUrl().toString());
|
||||
const auto remotePath = Utility::noLeadingSlashPath(propagator()->fullRemotePath(_fileToUpload._file));
|
||||
const auto destination = QString(davUrl + remotePath);
|
||||
return destination.toUtf8();
|
||||
}
|
||||
|
||||
void PropagateUploadFileNG::doStartUpload()
|
||||
{
|
||||
propagator()->_activeJobList.append(this);
|
||||
|
@ -268,6 +276,7 @@ void PropagateUploadFileNG::startNewUpload()
|
|||
|
||||
// But we should send the temporary (or something) one.
|
||||
headers["OC-Total-Length"] = QByteArray::number(_fileToUpload._size);
|
||||
headers["Destination"] = destinationHeader();
|
||||
const auto job = new MkColJob(propagator()->account(), chunkUploadFolderUrl(), headers, this);
|
||||
|
||||
connect(job, &MkColJob::finishedWithError,
|
||||
|
@ -360,11 +369,9 @@ void PropagateUploadFileNG::startNextChunk()
|
|||
return;
|
||||
}
|
||||
|
||||
auto headers = PropagateUploadFileCommon::headers();
|
||||
QMap<QByteArray, QByteArray> headers;
|
||||
headers["OC-Chunk-Offset"] = QByteArray::number(_sent);
|
||||
|
||||
const auto destination = QDir::cleanPath(propagator()->account()->davUrl().path() + propagator()->fullRemotePath(_fileToUpload._file));
|
||||
headers["Destination"] = destination.toUtf8();
|
||||
headers["Destination"] = destinationHeader();
|
||||
|
||||
_sent += _currentChunkSize;
|
||||
const auto url = chunkUrl(_currentChunk);
|
||||
|
|
Загрузка…
Ссылка в новой задаче