mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-23 21:05:44 +03:00
PropagateUpload: Avoid many allocations by using QByteArrayLiteral
This commit is contained in:
parent
d6a0290058
commit
1783db5811
3 changed files with 16 additions and 16 deletions
|
@ -705,11 +705,11 @@ void PropagateUploadFileCommon::abortWithError(SyncFileItem::Status status, cons
|
|||
QMap<QByteArray, QByteArray> PropagateUploadFileCommon::headers()
|
||||
{
|
||||
QMap<QByteArray, QByteArray> headers;
|
||||
headers["OC-Async"] = "1";
|
||||
headers["Content-Type"] = "application/octet-stream";
|
||||
headers["X-OC-Mtime"] = QByteArray::number(qint64(_item->_modtime));
|
||||
headers[QByteArrayLiteral("OC-Async")] = QByteArrayLiteral("1");
|
||||
headers[QByteArrayLiteral("Content-Type")] = QByteArrayLiteral("application/octet-stream");
|
||||
headers[QByteArrayLiteral("X-OC-Mtime")] = QByteArray::number(qint64(_item->_modtime));
|
||||
|
||||
if (_item->_file.contains(".sys.admin#recall#")) {
|
||||
if (_item->_file.contains(QLatin1String(".sys.admin#recall#"))) {
|
||||
// This is a file recall triggered by the admin. Note: the
|
||||
// recall list file created by the admin and downloaded by the
|
||||
// client (.sys.admin#recall#) also falls into this category
|
||||
|
@ -726,21 +726,21 @@ QMap<QByteArray, QByteArray> PropagateUploadFileCommon::headers()
|
|||
&& !_deleteExisting) {
|
||||
// We add quotes because the owncloud server always adds quotes around the etag, and
|
||||
// csync_owncloud.c's owncloud_file_id always strips the quotes.
|
||||
headers["If-Match"] = '"' + _item->_etag + '"';
|
||||
headers[QByteArrayLiteral("If-Match")] = '"' + _item->_etag + '"';
|
||||
}
|
||||
|
||||
// Set up a conflict file header pointing to the original file
|
||||
auto conflictRecord = propagator()->_journal->conflictRecord(_item->_file.toUtf8());
|
||||
if (conflictRecord.isValid()) {
|
||||
headers["OC-Conflict"] = "1";
|
||||
headers[QByteArrayLiteral("OC-Conflict")] = "1";
|
||||
if (!conflictRecord.initialBasePath.isEmpty())
|
||||
headers["OC-ConflictInitialBasePath"] = conflictRecord.initialBasePath;
|
||||
headers[QByteArrayLiteral("OC-ConflictInitialBasePath")] = conflictRecord.initialBasePath;
|
||||
if (!conflictRecord.baseFileId.isEmpty())
|
||||
headers["OC-ConflictBaseFileId"] = conflictRecord.baseFileId;
|
||||
headers[QByteArrayLiteral("OC-ConflictBaseFileId")] = conflictRecord.baseFileId;
|
||||
if (conflictRecord.baseModtime != -1)
|
||||
headers["OC-ConflictBaseMtime"] = QByteArray::number(conflictRecord.baseModtime);
|
||||
headers[QByteArrayLiteral("OC-ConflictBaseMtime")] = QByteArray::number(conflictRecord.baseModtime);
|
||||
if (!conflictRecord.baseEtag.isEmpty())
|
||||
headers["OC-ConflictBaseEtag"] = conflictRecord.baseEtag;
|
||||
headers[QByteArrayLiteral("OC-ConflictBaseEtag")] = conflictRecord.baseEtag;
|
||||
}
|
||||
|
||||
if (_uploadEncryptedHelper && !_uploadEncryptedHelper->_folderToken.isEmpty()) {
|
||||
|
|
|
@ -295,15 +295,15 @@ void PropagateUploadFileNG::startNextChunk()
|
|||
auto headers = PropagateUploadFileCommon::headers();
|
||||
|
||||
// "If-Match applies to the source, but we are interested in comparing the etag of the destination
|
||||
auto ifMatch = headers.take("If-Match");
|
||||
auto ifMatch = headers.take(QByteArrayLiteral("If-Match"));
|
||||
if (!ifMatch.isEmpty()) {
|
||||
headers["If"] = "<" + QUrl::toPercentEncoding(destination, "/") + "> ([" + ifMatch + "])";
|
||||
headers[QByteArrayLiteral("If")] = "<" + QUrl::toPercentEncoding(destination, "/") + "> ([" + ifMatch + "])";
|
||||
}
|
||||
if (!_transmissionChecksumHeader.isEmpty()) {
|
||||
qCInfo(lcPropagateUpload) << destination << _transmissionChecksumHeader;
|
||||
headers[checkSumHeaderC] = _transmissionChecksumHeader;
|
||||
}
|
||||
headers["OC-Total-Length"] = QByteArray::number(fileSize);
|
||||
headers[QByteArrayLiteral("OC-Total-Length")] = QByteArray::number(fileSize);
|
||||
|
||||
auto job = new MoveJob(propagator()->account(), Utility::concatUrlPath(chunkUrl(), "/.file"),
|
||||
destination, headers, this);
|
||||
|
|
|
@ -85,8 +85,8 @@ void PropagateUploadFileV1::startNextChunk()
|
|||
}
|
||||
quint64 fileSize = _fileToUpload._size;
|
||||
auto headers = PropagateUploadFileCommon::headers();
|
||||
headers["OC-Total-Length"] = QByteArray::number(fileSize);
|
||||
headers["OC-Chunk-Size"] = QByteArray::number(quint64(chunkSize()));
|
||||
headers[QByteArrayLiteral("OC-Total-Length")] = QByteArray::number(fileSize);
|
||||
headers[QByteArrayLiteral("OC-Chunk-Size")] = QByteArray::number(quint64(chunkSize()));
|
||||
|
||||
QString path = _fileToUpload._file;
|
||||
|
||||
|
@ -101,7 +101,7 @@ void PropagateUploadFileV1::startNextChunk()
|
|||
qCInfo(lcPropagateUpload) << "Upload chunk" << sendingChunk << "of" << _chunkCount << "transferid(remote)=" << transid;
|
||||
path += QString("-chunking-%1-%2-%3").arg(transid).arg(_chunkCount).arg(sendingChunk);
|
||||
|
||||
headers["OC-Chunked"] = "1";
|
||||
headers[QByteArrayLiteral("OC-Chunked")] = QByteArrayLiteral("1");
|
||||
|
||||
chunkStart = chunkSize() * quint64(sendingChunk);
|
||||
currentChunkSize = chunkSize();
|
||||
|
|
Loading…
Reference in a new issue