"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/common/checksums.cpp" between
ownCloud-2.7.5.3180.tar.xz and ownCloud-2.7.6.3261.tar.xz

About: ownCloud Client (formerly "mirall") is a tool to synchronize files from ownCloud Server with your desktop client. It uses OCSync as its syncing backend.

checksums.cpp  (ownCloud-2.7.5.3180.tar.xz):checksums.cpp  (ownCloud-2.7.6.3261.tar.xz)
skipping to change at line 145 skipping to change at line 145
QByteArray makeChecksumHeader(const QByteArray &checksumType, const QByteArray & checksum) QByteArray makeChecksumHeader(const QByteArray &checksumType, const QByteArray & checksum)
{ {
if (checksumType.isEmpty() || checksum.isEmpty()) if (checksumType.isEmpty() || checksum.isEmpty())
return QByteArray(); return QByteArray();
QByteArray header = checksumType; QByteArray header = checksumType;
header.append(':'); header.append(':');
header.append(checksum); header.append(checksum);
return header; return header;
} }
QByteArray findBestChecksum(const QByteArray &checksums) QByteArray findBestChecksum(const QByteArray &_checksums)
{ {
if (_checksums.isEmpty()) {
return {};
}
const auto checksums = QString::fromUtf8(_checksums);
int i = 0; int i = 0;
// The order of the searches here defines the preference ordering. // The order of the searches here defines the preference ordering.
if (-1 != (i = checksums.indexOf("SHA3-256:")) if (-1 != (i = checksums.indexOf(QLatin1String("SHA3-256:"), 0, Qt::CaseInse
|| -1 != (i = checksums.indexOf("SHA256:")) nsitive))
|| -1 != (i = checksums.indexOf("SHA1:")) || -1 != (i = checksums.indexOf(QLatin1String("SHA256:"), 0, Qt::CaseIns
|| -1 != (i = checksums.indexOf("MD5:")) ensitive))
|| -1 != (i = checksums.indexOf("Adler32:"))) { || -1 != (i = checksums.indexOf(QLatin1String("SHA1:"), 0, Qt::CaseInsen
sitive))
|| -1 != (i = checksums.indexOf(QLatin1String("MD5:"), 0, Qt::CaseInsens
itive))
|| -1 != (i = checksums.indexOf(QLatin1String("ADLER32:"), 0, Qt::CaseIn
sensitive))) {
// Now i is the start of the best checksum // Now i is the start of the best checksum
// Grab it until the next space or end of string. // Grab it until the next space or end of xml or end of string.
auto checksum = checksums.mid(i); int end = _checksums.indexOf(' ', i);
return checksum.mid(0, checksum.indexOf(" ")); // workaround for https://github.com/owncloud/core/pull/38304
if (end == -1) {
end = _checksums.indexOf('<', i);
}
return _checksums.mid(i, end - i);
} }
return QByteArray(); qCWarning(lcChecksums) << "Failed to parse" << _checksums;
return {};
} }
bool parseChecksumHeader(const QByteArray &header, QByteArray *type, QByteArray *checksum) bool parseChecksumHeader(const QByteArray &header, QByteArray *type, QByteArray *checksum)
{ {
if (header.isEmpty()) { if (header.isEmpty()) {
type->clear(); type->clear();
checksum->clear(); checksum->clear();
return true; return true;
} }
 End of changes. 5 change blocks. 
10 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)