From aaca3e7ce59c83a5dc69f2386447d82ea25cadcb Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Wed, 13 May 2020 17:34:41 +0200 Subject: [PATCH] Use separate loggin category for upload v1 and ng --- src/libsync/propagateupload.cpp | 2 ++ src/libsync/propagateupload.h | 2 ++ src/libsync/propagateuploadng.cpp | 18 +++++++++--------- src/libsync/propagateuploadv1.cpp | 14 +++++++------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index 519fb36c9..14c6416d3 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -46,6 +46,8 @@ namespace OCC { Q_LOGGING_CATEGORY(lcPutJob, "nextcloud.sync.networkjob.put", QtInfoMsg) Q_LOGGING_CATEGORY(lcPollJob, "nextcloud.sync.networkjob.poll", QtInfoMsg) Q_LOGGING_CATEGORY(lcPropagateUpload, "nextcloud.sync.propagator.upload", QtInfoMsg) +Q_LOGGING_CATEGORY(lcPropagateUploadV1, "nextcloud.sync.propagator.upload.v1", QtInfoMsg) +Q_LOGGING_CATEGORY(lcPropagateUploadNG, "nextcloud.sync.propagator.upload.ng", QtInfoMsg) /** * We do not want to upload files that are currently being modified. diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index 2d2543171..f9e239abd 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -25,6 +25,8 @@ namespace OCC { Q_DECLARE_LOGGING_CATEGORY(lcPutJob) Q_DECLARE_LOGGING_CATEGORY(lcPropagateUpload) +Q_DECLARE_LOGGING_CATEGORY(lcPropagateUploadV1) +Q_DECLARE_LOGGING_CATEGORY(lcPropagateUploadNG) class BandwidthManager; diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 29c549ea0..8ed62ae08 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -141,7 +141,7 @@ void PropagateUploadFileNG::slotPropfindFinished() if (_sent > _fileToUpload._size) { // Normally this can't happen because the size is xor'ed with the transfer id, and it is // therefore impossible that there is more data on the server than on the file. - qCCritical(lcPropagateUpload) << "Inconsistency while resuming " << _item->_file + qCCritical(lcPropagateUploadNG) << "Inconsistency while resuming " << _item->_file << ": the size on the server (" << _sent << ") is bigger than the size of the file (" << _fileToUpload._size << ")"; @@ -154,10 +154,10 @@ void PropagateUploadFileNG::slotPropfindFinished() return; } - qCInfo(lcPropagateUpload) << "Resuming " << _item->_file << " from chunk " << _currentChunk << "; sent =" << _sent; + qCInfo(lcPropagateUploadNG) << "Resuming " << _item->_file << " from chunk " << _currentChunk << "; sent =" << _sent; if (!_serverChunks.isEmpty()) { - qCInfo(lcPropagateUpload) << "To Delete" << _serverChunks.keys(); + qCInfo(lcPropagateUploadNG) << "To Delete" << _serverChunks.keys(); propagator()->_activeJobList.append(this); _removeJobError = false; @@ -208,7 +208,7 @@ void PropagateUploadFileNG::slotDeleteJobFinished() abortWithError(status, job->errorString()); return; } else { - qCWarning(lcPropagateUpload) << "DeleteJob errored out" << job->errorString() << job->reply()->url(); + qCWarning(lcPropagateUploadNG) << "DeleteJob errored out" << job->errorString() << job->reply()->url(); _removeJobError = true; // Let the other jobs finish } @@ -320,7 +320,7 @@ void PropagateUploadFileNG::startNextChunk() auto device = std::make_unique( fileName, _currentChunk, _currentChunkSize, &propagator()->_bandwidthManager); if (!device->open(QIODevice::ReadOnly)) { - qCWarning(lcPropagateUpload) << "Could not prepare upload device: " << device->errorString(); + qCWarning(lcPropagateUploadNG) << "Could not prepare upload device: " << device->errorString(); // If the file is currently locked, we want to retry the sync // when it becomes available again. @@ -401,7 +401,7 @@ void PropagateUploadFileNG::slotPutFinished() targetSize, propagator()->syncOptions()._maxChunkSize); - qCInfo(lcPropagateUpload) << "Chunked upload of" << _currentChunkSize << "bytes took" << uploadTime.count() + qCInfo(lcPropagateUploadNG) << "Chunked upload of" << _currentChunkSize << "bytes took" << uploadTime.count() << "ms, desired is" << targetDuration.count() << "ms, expected good chunk size is" << predictedGoodSize << "bytes and nudged next chunk size to " << propagator()->_chunkSize << "bytes"; @@ -478,13 +478,13 @@ void PropagateUploadFileNG::slotMoveJobFinished() QByteArray fid = job->reply()->rawHeader("OC-FileID"); if (fid.isEmpty()) { - qCWarning(lcPropagateUpload) << "Server did not return a OC-FileID" << _item->_file; + qCWarning(lcPropagateUploadNG) << "Server did not return a OC-FileID" << _item->_file; abortWithError(SyncFileItem::NormalError, tr("Missing File ID from server")); return; } else { // the old file id should only be empty for new files uploaded if (!_item->_fileId.isEmpty() && _item->_fileId != fid) { - qCWarning(lcPropagateUpload) << "File ID changed!" << _item->_fileId << fid; + qCWarning(lcPropagateUploadNG) << "File ID changed!" << _item->_fileId << fid; } _item->_fileId = fid; } @@ -492,7 +492,7 @@ void PropagateUploadFileNG::slotMoveJobFinished() _item->_etag = getEtagFromReply(job->reply()); ; if (_item->_etag.isEmpty()) { - qCWarning(lcPropagateUpload) << "Server did not return an ETAG" << _item->_file; + qCWarning(lcPropagateUploadNG) << "Server did not return an ETAG" << _item->_file; abortWithError(SyncFileItem::NormalError, tr("Missing ETag from server")); return; } diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index 93950c313..432642f25 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -47,7 +47,7 @@ void PropagateUploadFileV1::doStartUpload() && (progressInfo._contentChecksum == _item->_checksumHeader || progressInfo._contentChecksum.isEmpty() || _item->_checksumHeader.isEmpty())) { _startChunk = progressInfo._chunk; _transferId = progressInfo._transferid; - qCInfo(lcPropagateUpload) << _item->_file << ": Resuming from chunk " << _startChunk; + qCInfo(lcPropagateUploadV1) << _item->_file << ": Resuming from chunk " << _startChunk; } else if (_chunkCount <= 1 && !_item->_checksumHeader.isEmpty()) { // If there is only one chunk, write the checksum in the database, so if the PUT is sent // to the server, but the connection drops before we get the etag, we can check the checksum @@ -97,7 +97,7 @@ void PropagateUploadFileV1::startNextChunk() int sendingChunk = (_currentChunk + _startChunk) % _chunkCount; // XOR with chunk size to make sure everything goes well if chunk size changes between runs uint transid = _transferId ^ uint(chunkSize()); - qCInfo(lcPropagateUpload) << "Upload chunk" << sendingChunk << "of" << _chunkCount << "transferid(remote)=" << transid; + qCInfo(lcPropagateUploadV1) << "Upload chunk" << sendingChunk << "of" << _chunkCount << "transferid(remote)=" << transid; path += QString("-chunking-%1-%2-%3").arg(transid).arg(_chunkCount).arg(sendingChunk); headers[QByteArrayLiteral("OC-Chunked")] = QByteArrayLiteral("1"); @@ -115,10 +115,10 @@ void PropagateUploadFileV1::startNextChunk() // if there's only one chunk, it's the final one isFinalChunk = true; } - qCDebug(lcPropagateUpload) << _chunkCount << isFinalChunk << chunkStart << currentChunkSize; + qCDebug(lcPropagateUploadV1) << _chunkCount << isFinalChunk << chunkStart << currentChunkSize; if (isFinalChunk && !_transmissionChecksumHeader.isEmpty()) { - qCInfo(lcPropagateUpload) << propagator()->_remoteFolder + path << _transmissionChecksumHeader; + qCInfo(lcPropagateUploadV1) << propagator()->_remoteFolder + path << _transmissionChecksumHeader; headers[checkSumHeaderC] = _transmissionChecksumHeader; } @@ -126,7 +126,7 @@ void PropagateUploadFileV1::startNextChunk() auto device = std::make_unique( fileName, chunkStart, currentChunkSize, &propagator()->_bandwidthManager); if (!device->open(QIODevice::ReadOnly)) { - qCWarning(lcPropagateUpload) << "Could not prepare upload device: " << device->errorString(); + qCWarning(lcPropagateUploadV1) << "Could not prepare upload device: " << device->errorString(); // If the file is currently locked, we want to retry the sync // when it becomes available again. @@ -301,7 +301,7 @@ void PropagateUploadFileV1::slotPutFinished() QByteArray fid = job->reply()->rawHeader("OC-FileID"); if (!fid.isEmpty()) { if (!_item->_fileId.isEmpty() && _item->_fileId != fid) { - qCWarning(lcPropagateUpload) << "File ID changed!" << _item->_fileId << fid; + qCWarning(lcPropagateUploadV1) << "File ID changed!" << _item->_fileId << fid; } _item->_fileId = fid; } @@ -311,7 +311,7 @@ void PropagateUploadFileV1::slotPutFinished() if (job->reply()->rawHeader("X-OC-MTime") != "accepted") { // X-OC-MTime is supported since owncloud 5.0. But not when chunking. // Normally Owncloud 6 always puts X-OC-MTime - qCWarning(lcPropagateUpload) << "Server does not support X-OC-MTime" << job->reply()->rawHeader("X-OC-MTime"); + qCWarning(lcPropagateUploadV1) << "Server does not support X-OC-MTime" << job->reply()->rawHeader("X-OC-MTime"); // Well, the mtime was not set } -- 2.30.2