Skip to content

Commit

Permalink
Merge pull request #5871 from nextcloud/bugfix/bulkUploadEmptyFiles
Browse files Browse the repository at this point in the history
fix bulk upload of empty files
  • Loading branch information
mgallien committed Jul 10, 2023
2 parents 0bb0491 + 5540f7f commit e25c59e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion craftmaster.ini
Expand Up @@ -30,7 +30,7 @@ ShortPath/EnableJunctions = False

; Packager/RepositoryUrl = https://files.kde.org/craft/
Packager/PackageType = NullsoftInstallerPackager
Packager/RepositoryUrl = http://ftp.acc.umu.se/mirror/kde.org/files/craft/master/
Packager/RepositoryUrl = https://files.kde.org/craft/master/

ContinuousIntegration/Enabled = True

Expand Down
24 changes: 6 additions & 18 deletions src/common/checksumcalculator.cpp
Expand Up @@ -95,8 +95,6 @@ QByteArray ChecksumCalculator::calculate()
return result;
}

bool isAnyChunkAdded = false;

for (;;) {
QMutexLocker locker(&_deviceMutex);
if (!_device->isOpen() || _device->atEnd()) {
Expand All @@ -114,7 +112,6 @@ QByteArray ChecksumCalculator::calculate()
if (!addChunk(buf, sizeRead)) {
break;
}
isAnyChunkAdded = true;
}

{
Expand All @@ -124,14 +121,12 @@ QByteArray ChecksumCalculator::calculate()
}
}

if (isAnyChunkAdded) {
if (_algorithmType == AlgorithmType::Adler32) {
result = QByteArray::number(_adlerHash, 16);
} else {
Q_ASSERT(_cryptographicHash);
if (_cryptographicHash) {
result = _cryptographicHash->result().toHex();
}
if (_algorithmType == AlgorithmType::Adler32) {
result = QByteArray::number(_adlerHash, 16);
} else {
Q_ASSERT(_cryptographicHash);
if (_cryptographicHash) {
result = _cryptographicHash->result().toHex();
}
}

Expand All @@ -152,13 +147,6 @@ void ChecksumCalculator::initChecksumAlgorithm()
return;
}

{
QMutexLocker locker(&_deviceMutex);
if (_device->size() == 0) {
return;
}
}

if (_algorithmType == AlgorithmType::Adler32) {
_adlerHash = adler32(0L, Z_NULL, 0);
} else {
Expand Down
6 changes: 5 additions & 1 deletion src/libsync/putmultifilejob.cpp
Expand Up @@ -53,7 +53,11 @@ void PutMultiFileJob::start()

auto onePart = QHttpPart{};

onePart.setBodyDevice(oneDevice._device.get());
if (oneDevice._device->size() == 0) {
onePart.setBody({});
} else {
onePart.setBodyDevice(oneDevice._device.get());
}

for (auto it = oneDevice._headers.begin(); it != oneDevice._headers.end(); ++it) {
onePart.setRawHeader(it.key(), it.value());
Expand Down

0 comments on commit e25c59e

Please sign in to comment.