Skip to content
2 changes: 1 addition & 1 deletion src/common/checksums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"

Check failure on line 18 in src/common/checksums.cpp

View workflow job for this annotation

GitHub Actions / build

src/common/checksums.cpp:18:10 [clang-diagnostic-error]

'config.h' file not found
#include "filesystembase.h"
#include "common/checksums.h"
#include "checksumcalculator.h"
Expand Down Expand Up @@ -201,7 +201,7 @@

void ComputeChecksum::start(const QString &filePath)
{
qCInfo(lcChecksums) << "Computing" << checksumType() << "checksum of" << filePath << "in a thread";
qCDebug(lcChecksums) << "Computing" << checksumType() << "checksum of" << filePath << "in a thread";
startImpl(filePath);
}

Expand Down
10 changes: 4 additions & 6 deletions src/common/syncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <QCryptographicHash>

Check failure on line 19 in src/common/syncjournaldb.cpp

View workflow job for this annotation

GitHub Actions / build

src/common/syncjournaldb.cpp:19:10 [clang-diagnostic-error]

'QCryptographicHash' file not found
#include <QFile>
#include <QLoggingCategory>
#include <QStringList>
Expand Down Expand Up @@ -1711,13 +1711,11 @@
res->_valid = ok;
}

static bool deleteBatch(SqlQuery &query, const QStringList &entries, const QString &name)
static bool deleteBatch(SqlQuery &query, const QStringList &entries)

Check warning on line 1714 in src/common/syncjournaldb.cpp

View workflow job for this annotation

GitHub Actions / build

src/common/syncjournaldb.cpp:1714:13 [modernize-use-trailing-return-type]

use a trailing return type for this function
{
if (entries.isEmpty())
return true;

qCDebug(lcDb) << "Removing stale" << name << "entries:" << entries.join(QStringLiteral(", "));
// FIXME: Was ported from execBatch, check if correct!
for (const auto &entry : entries) {
query.reset_and_clear_bindings();
query.bindValue(1, entry);
Expand Down Expand Up @@ -1831,7 +1829,7 @@
qCDebug(lcDb) << "database error:" << query->error();
return empty_result;
}
if (!deleteBatch(*query, superfluousPaths, QStringLiteral("downloadinfo"))) {
if (!deleteBatch(*query, superfluousPaths)) {
return empty_result;
}
}
Expand Down Expand Up @@ -1965,7 +1963,7 @@
}

const auto deleteUploadInfoQuery = _queryManager.get(PreparedSqlQueryManager::DeleteUploadInfoQuery);
deleteBatch(*deleteUploadInfoQuery, superfluousPaths, QStringLiteral("uploadinfo"));
deleteBatch(*deleteUploadInfoQuery, superfluousPaths);
return ids;
}

Expand Down Expand Up @@ -2033,7 +2031,7 @@

SqlQuery delQuery(_db);
delQuery.prepare("DELETE FROM blacklist WHERE path = ?");
return deleteBatch(delQuery, superfluousPaths, QStringLiteral("blacklist"));
return deleteBatch(delQuery, superfluousPaths);
}

void SyncJournalDb::deleteStaleFlagsEntries()
Expand Down
5 changes: 0 additions & 5 deletions src/gui/folderwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ void FolderWatcher::changeDetected(const QStringList &paths)
_lockedFiles.insert(checkResult.path);
}

qCDebug(lcFolderWatcher) << "Locked files:" << _lockedFiles.values();

// ------- handle ignores:
if (pathIsIgnored(path)) {
continue;
Expand All @@ -233,9 +231,6 @@ void FolderWatcher::changeDetected(const QStringList &paths)
changedPaths.insert(path);
}

qCDebug(lcFolderWatcher) << "Unlocked files:" << _unlockedFiles.values();
qCDebug(lcFolderWatcher) << "Locked files:" << _lockedFiles;

if (!_lockedFiles.isEmpty() || !_unlockedFiles.isEmpty()) {
if (_lockChangeDebouncingTimer.isActive()) {
_lockChangeDebouncingTimer.stop();
Expand Down
18 changes: 10 additions & 8 deletions src/libsync/bulkpropagatorjob.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* Copyright 2021 (c) Matthieu Gallien <matthieu.gallien@nextcloud.com>
*
Expand Down Expand Up @@ -58,7 +58,6 @@
return reply.value(headerName).toString().toLatin1();
}

constexpr auto batchSize = 100;
constexpr auto parallelJobsMaximumCount = 1;

}
Expand All @@ -70,10 +69,10 @@
BulkPropagatorJob::BulkPropagatorJob(OwncloudPropagator *propagator, const std::deque<SyncFileItemPtr> &items)
: PropagatorJob(propagator)
, _items(items)
, _currentBatchSize(batchSize)
, _currentBatchSize(_items.size())
{
_filesToUpload.reserve(batchSize);
_pendingChecksumFiles.reserve(batchSize);
_filesToUpload.reserve(_items.size());
_pendingChecksumFiles.reserve(_items.size());
}

bool BulkPropagatorJob::scheduleSelfOrChild()
Expand All @@ -84,11 +83,15 @@

_state = Running;

for(auto i = 0; i < _currentBatchSize && !_items.empty(); ++i) {
qCDebug(lcBulkPropagatorJob()) << "max chunk size" << PropagatorJob::propagator()->syncOptions().maxChunkSize();

for(auto batchDataSize = 0; batchDataSize <= PropagatorJob::propagator()->syncOptions().maxChunkSize() && !_items.empty(); ) {
const auto currentItem = _items.front();
_items.pop_front();
_pendingChecksumFiles.insert(currentItem->_file);

batchDataSize += currentItem->_size;

QMetaObject::invokeMethod(this, [this, currentItem] {
UploadFileInfo fileToUpload;
fileToUpload._file = currentItem->_file;
Expand Down Expand Up @@ -117,7 +120,7 @@
}

// change batch size before trying it again
const auto halfBatchSize = batchSize / 2;
const auto halfBatchSize = static_cast<int>(_items.size() / 2);

// we already tried to upload with half of the batch size
if(_currentBatchSize == halfBatchSize) {
Expand Down Expand Up @@ -221,7 +224,6 @@
remotePath, fileToUpload._path,
fileToUpload._size, currentHeaders};

qCInfo(lcBulkPropagatorJob) << remotePath << "transmission checksum" << transmissionChecksumHeader << fileToUpload._path;
_filesToUpload.push_back(std::move(newUploadFile));
_pendingChecksumFiles.remove(item->_file);

Expand Down Expand Up @@ -583,7 +585,7 @@

void BulkPropagatorJob::finalize(const QJsonObject &fullReply)
{
qCDebug(lcBulkPropagatorJob) << "Received a full reply" << fullReply;
qCDebug(lcBulkPropagatorJob) << "Received a full reply" << QJsonDocument::fromVariant(fullReply).toJson();

for(auto singleFileIt = std::begin(_filesToUpload); singleFileIt != std::end(_filesToUpload); ) {
const auto &singleFile = *singleFileIt;
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* for more details.
*/

#include "config.h"

Check failure on line 15 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:15:10 [clang-diagnostic-error]

'config.h' file not found

#include "configfile.h"
#include "theme.h"
Expand Down Expand Up @@ -272,13 +272,13 @@
qint64 ConfigFile::maxChunkSize() const
{
QSettings settings(configFile(), QSettings::IniFormat);
return settings.value(QLatin1String(maxChunkSizeC), 5LL * 1000LL * 1000LL * 1000LL).toLongLong(); // default to 5000 MB
return settings.value(QLatin1String(maxChunkSizeC), 100LL * 1024LL * 1024LL).toLongLong(); // default to 100 MiB
}

qint64 ConfigFile::minChunkSize() const
{
QSettings settings(configFile(), QSettings::IniFormat);
return settings.value(QLatin1String(minChunkSizeC), 5LL * 1000LL * 1000LL).toLongLong(); // default to 5 MB
return settings.value(QLatin1String(minChunkSizeC), 5LL * 1024LL * 1024LL).toLongLong(); // default to 5 MiB
}

chrono::milliseconds ConfigFile::targetChunkUploadDuration() const
Expand Down
4 changes: 3 additions & 1 deletion src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,9 @@ bool PropagatorCompositeJob::scheduleSelfOrChild()
_tasksToDo.remove(0);
PropagatorJob *job = propagator()->createJob(nextTask);
if (!job) {
qCWarning(lcDirectory) << "Useless task found for file" << nextTask->destination() << "instruction" << nextTask->_instruction;
if (!propagator()->isDelayedUploadItem(nextTask)) {
qCWarning(lcDirectory) << "Useless task found for file" << nextTask->destination() << "instruction" << nextTask->_instruction;
}
continue;
}
appendJob(job);
Expand Down
13 changes: 11 additions & 2 deletions src/libsync/propagateupload.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* Copyright (C) by Olivier Goffart <ogoffart@owncloud.com>
*
Expand All @@ -12,7 +12,7 @@
* for more details.
*/

#include "config.h"

Check failure on line 15 in src/libsync/propagateupload.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/propagateupload.cpp:15:10 [clang-diagnostic-error]

'config.h' file not found
#include "propagateupload.h"
#include "propagateuploadencrypted.h"
#include "owncloudpropagator_p.h"
Expand Down Expand Up @@ -64,18 +64,27 @@

req.setPriority(QNetworkRequest::LowPriority); // Long uploads must not block non-propagation jobs.

auto requestID = QByteArray{};

if (_url.isValid()) {
sendRequest("PUT", _url, req, _device);
const auto reply = sendRequest("PUT", _url, req, _device);
requestID = reply->request().rawHeader("X-Request-ID");
} else {
sendRequest("PUT", makeDavUrl(path()), req, _device);
const auto reply = sendRequest("PUT", makeDavUrl(path()), req, _device);
requestID = reply->request().rawHeader("X-Request-ID");
}

if (reply()->error() != QNetworkReply::NoError) {
qCWarning(lcPutJob) << " Network error: " << reply()->errorString();
}

connect(reply(), &QNetworkReply::uploadProgress, this, [requestID] (qint64 bytesSent, qint64 bytesTotal) {
qCDebug(lcPutJob()) << requestID << "upload progress" << bytesSent << bytesTotal;
});

connect(reply(), &QNetworkReply::uploadProgress, this, &PUTFileJob::uploadProgress);
connect(this, &AbstractNetworkJob::networkActivity, account().data(), &Account::propagatorNetworkActivity);

_requestTimer.start();
AbstractNetworkJob::start();
}
Expand Down
26 changes: 15 additions & 11 deletions src/libsync/putmultifilejob.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* Copyright 2021 (c) Matthieu Gallien <matthieu.gallien@nextcloud.com>
*
Expand Down Expand Up @@ -32,8 +32,6 @@

for(const auto &singleDevice : _devices) {
singleDevice._device->setParent(this);
connect(this, &PutMultiFileJob::uploadProgress,
singleDevice._device.get(), &UploadDevice::slotJobUploadProgress);
}
}

Expand All @@ -56,7 +54,12 @@
if (oneDevice._device->size() == 0) {
onePart.setBody({});
} else {
onePart.setBodyDevice(oneDevice._device.get());
const auto allData = oneDevice._device->readAll();
onePart.setBody(allData);
}

if (oneDevice._device->isOpen()) {
oneDevice._device->close();
}

for (auto it = oneDevice._headers.begin(); it != oneDevice._headers.end(); ++it) {
Expand All @@ -68,13 +71,17 @@
_body.append(onePart);
}

sendRequest("POST", _url, req, &_body);
const auto newReply = sendRequest("POST", _url, req, &_body);
const auto &requestID = newReply->request().rawHeader("X-Request-ID");

if (reply()->error() != QNetworkReply::NoError) {
qCWarning(lcPutMultiFileJob) << " Network error: " << reply()->errorString();
}

connect(reply(), &QNetworkReply::uploadProgress, this, &PutMultiFileJob::uploadProgress);
connect(reply(), &QNetworkReply::uploadProgress, this, [requestID] (qint64 bytesSent, qint64 bytesTotal) {
qCDebug(lcPutMultiFileJob()) << requestID << "upload progress" << bytesSent << bytesTotal;
});
connect(this, &AbstractNetworkJob::networkActivity, account().data(), &Account::propagatorNetworkActivity);
_requestTimer.start();
AbstractNetworkJob::start();
Expand All @@ -90,15 +97,12 @@
for(const auto &oneDevice : _devices) {
Q_ASSERT(oneDevice._device);

if (!oneDevice._device->errorString().isEmpty()) {
qCWarning(lcPutMultiFileJob) << "oneDevice has error:" << oneDevice._device->errorString();
}

if (oneDevice._device->isOpen()) {
if (!oneDevice._device->errorString().isEmpty()) {
qCWarning(lcPutMultiFileJob) << "oneDevice has error:" << oneDevice._device->errorString();
}

oneDevice._device->close();
} else {
qCWarning(lcPutMultiFileJob) << "Did not close device" << oneDevice._device.get()
<< "as it was not open";
}
}

Expand Down
1 change: 0 additions & 1 deletion src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemVector &syncItems)
_journal->getAndDeleteStaleDownloadInfos(download_file_paths);
for (const SyncJournalDb::DownloadInfo &deleted_info : deleted_infos) {
const QString tmppath = _propagator->fullLocalPath(deleted_info._tmpfile);
qCInfo(lcEngine) << "Deleting stale temporary file: " << tmppath;
FileSystem::remove(tmppath);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/

#include <QtTest>

Check failure on line 8 in test/testsyncengine.cpp

View workflow job for this annotation

GitHub Actions / build

test/testsyncengine.cpp:8:10 [clang-diagnostic-error]

'QtTest' file not found
#include <QTextCodec>

#include "syncenginetestutils.h"
Expand Down Expand Up @@ -1208,7 +1208,7 @@

QVERIFY(fakeFolder.syncOnce());
QCOMPARE(nPUT, 0);
QCOMPARE(nPOST, 2);
QCOMPARE(nPOST, 1);
nPUT = 0;
nPOST = 0;

Expand All @@ -1219,7 +1219,7 @@

QVERIFY(!fakeFolder.syncOnce());
QCOMPARE(nPUT, 120);
QCOMPARE(nPOST, 2);
QCOMPARE(nPOST, 1);
nPUT = 0;
nPOST = 0;

Expand Down
Loading