Merge pull request #5871 from nextcloud/bugfix/bulkUploadEmptyFiles

fix bulk upload of empty files
This commit is contained in:
Matthieu Gallien 2023-07-10 17:56:07 +02:00 committed by GitHub
commit e25c59e0ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 20 deletions

View File

@ -30,7 +30,7 @@ ShortPath/EnableJunctions = False
; Packager/RepositoryUrl = https://files.kde.org/craft/ ; Packager/RepositoryUrl = https://files.kde.org/craft/
Packager/PackageType = NullsoftInstallerPackager 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 ContinuousIntegration/Enabled = True

View File

@ -95,8 +95,6 @@ QByteArray ChecksumCalculator::calculate()
return result; return result;
} }
bool isAnyChunkAdded = false;
for (;;) { for (;;) {
QMutexLocker locker(&_deviceMutex); QMutexLocker locker(&_deviceMutex);
if (!_device->isOpen() || _device->atEnd()) { if (!_device->isOpen() || _device->atEnd()) {
@ -114,7 +112,6 @@ QByteArray ChecksumCalculator::calculate()
if (!addChunk(buf, sizeRead)) { if (!addChunk(buf, sizeRead)) {
break; break;
} }
isAnyChunkAdded = true;
} }
{ {
@ -124,14 +121,12 @@ QByteArray ChecksumCalculator::calculate()
} }
} }
if (isAnyChunkAdded) { if (_algorithmType == AlgorithmType::Adler32) {
if (_algorithmType == AlgorithmType::Adler32) { result = QByteArray::number(_adlerHash, 16);
result = QByteArray::number(_adlerHash, 16); } else {
} else { Q_ASSERT(_cryptographicHash);
Q_ASSERT(_cryptographicHash); if (_cryptographicHash) {
if (_cryptographicHash) { result = _cryptographicHash->result().toHex();
result = _cryptographicHash->result().toHex();
}
} }
} }
@ -152,13 +147,6 @@ void ChecksumCalculator::initChecksumAlgorithm()
return; return;
} }
{
QMutexLocker locker(&_deviceMutex);
if (_device->size() == 0) {
return;
}
}
if (_algorithmType == AlgorithmType::Adler32) { if (_algorithmType == AlgorithmType::Adler32) {
_adlerHash = adler32(0L, Z_NULL, 0); _adlerHash = adler32(0L, Z_NULL, 0);
} else { } else {

View File

@ -53,7 +53,11 @@ void PutMultiFileJob::start()
auto onePart = QHttpPart{}; 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) { for (auto it = oneDevice._headers.begin(); it != oneDevice._headers.end(); ++it) {
onePart.setRawHeader(it.key(), it.value()); onePart.setRawHeader(it.key(), it.value());