From 3bf5913e151cbbdbbb6e0cecb1733ce395b99735 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Wed, 23 Oct 2024 17:01:21 +0700 Subject: [PATCH] Apply suggestions --- src/core/qfieldcloudprojectsmodel.cpp | 10 ++++++---- src/core/utils/fileutils.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/qfieldcloudprojectsmodel.cpp b/src/core/qfieldcloudprojectsmodel.cpp index cb45d12750..693f24015a 100644 --- a/src/core/qfieldcloudprojectsmodel.cpp +++ b/src/core/qfieldcloudprojectsmodel.cpp @@ -1037,20 +1037,22 @@ void QFieldCloudProjectsModel::projectDownload( const QString &projectId ) const int fileSize = fileObject.value( QStringLiteral( "size" ) ).toInt(); const QString fileName = fileObject.value( QStringLiteral( "name" ) ).toString(); const QString projectFileName = QStringLiteral( "%1/%2/%3/%4" ).arg( QFieldCloudUtils::localCloudDirectory(), mUsername, projectId, fileName ); - const QString cloudChecksum = fileObject.value( QStringLiteral( "md5sum" ) ).toString(); - const QString localChecksum = FileUtils::fileEtag( projectFileName ); + // NOTE the cloud API is giving the false impression that the file keys `md5sum` is having a MD5 or another checksum. + // This actually is an Object Storage (S3) implementation specific ETag. + const QString cloudEtag = fileObject.value( QStringLiteral( "md5sum" ) ).toString(); + const QString localEtag = FileUtils::fileEtag( projectFileName ); if ( !fileObject.value( QStringLiteral( "size" ) ).isDouble() || fileName.isEmpty() - || cloudChecksum.isEmpty() ) + || cloudEtag.isEmpty() ) { QgsLogger::debug( QStringLiteral( "Project %1: package in \"files\" list does not contain the expected fields: size(int), name(string), md5sum(string)" ).arg( projectId ) ); emit projectDownloadFinished( projectId, tr( "Latest package data structure error." ) ); return; } - if ( cloudChecksum == localChecksum ) + if ( cloudEtag == localEtag ) continue; project->downloadFileTransfers.insert( fileName, FileTransfer( fileName, fileSize ) ); diff --git a/src/core/utils/fileutils.h b/src/core/utils/fileutils.h index 34d2dd1c29..bb979dfb98 100644 --- a/src/core/utils/fileutils.h +++ b/src/core/utils/fileutils.h @@ -71,7 +71,7 @@ class QFIELD_CORE_EXPORT FileUtils : public QObject Q_INVOKABLE static QByteArray fileChecksum( const QString &fileName, const QCryptographicHash::Algorithm hashAlgorithm ); /** - * Returns an S3 ETag of a file. An empty string will be returned if it cannot be calculated. + * Returns an Object Storage (S3) ETag of a file. An empty string will be returned if it cannot be calculated. * \param fileName file name to get checksum of * \param partSize maximum size used to divide the file content into parts * \return QString Etag value