From 43f74b1e5f28b7fed135c6df2dd429cc5d6570c3 Mon Sep 17 00:00:00 2001 From: Peter Petrik Date: Tue, 3 Oct 2023 09:19:26 +0200 Subject: [PATCH] revert function return value --- core/merginapi.cpp | 29 ++++++++++++++--------------- core/merginapi.h | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/core/merginapi.cpp b/core/merginapi.cpp index 03744c23ae..6a9a889431 100644 --- a/core/merginapi.cpp +++ b/core/merginapi.cpp @@ -1496,7 +1496,7 @@ bool MerginApi::hasLocalProjectChanges( const QString &projectDir ) MerginConfig config = MerginConfig::fromFile( projectDir + "/" + sMerginConfigFile ); - return projectFilesEqual( projectMetadata.files, localFiles, projectDir ); + return hasLocalChanges( projectMetadata.files, localFiles, projectDir ); } QString MerginApi::getTempProjectDir( const QString &projectFullName ) @@ -2814,12 +2814,17 @@ void MerginApi::getWorkspaceInfoReplyFinished() r->deleteLater(); } -bool MerginApi::projectFilesEqual( +bool MerginApi::hasLocalChanges( const QList &oldServerFiles, const QList &localFiles, const QString &projectDir ) { + if (localFiles.count() != oldServerFiles.count()) + { + return true; + } + QHash oldServerFilesMap; for ( const MerginFile &file : oldServerFiles ) @@ -2835,7 +2840,7 @@ bool MerginApi::projectFilesEqual( if ( !hasOldServer ) { // L-A - return false; + return true; } else { @@ -2852,28 +2857,22 @@ bool MerginApi::projectFilesEqual( if ( GeodiffUtils::hasPendingChanges( projectDir, filePath ) ) { // L-U - return false; + return true; } } else { // L-U - return false; + return true; } } } - - if ( hasOldServer ) - oldServerFilesMap.remove( filePath ); } - if ( !oldServerFilesMap.empty() ) - { - // L-D - return false; - } - - return true; + // We know that the number of local files and old server is the same + // And also that all local files has old file counterpart + // So it is not possible that there is deleted local file at this point. + return false; } ProjectDiff MerginApi::compareProjectFiles( diff --git a/core/merginapi.h b/core/merginapi.h index 779bdc48f6..eedcbebefe 100644 --- a/core/merginapi.h +++ b/core/merginapi.h @@ -447,13 +447,13 @@ class MerginApi: public QObject * - "old" server version (what was downloaded from server) - read from the project directory's stored metadata * - local file version (what is currently in the project directory) - created on the fly from the local directory content * - * The function returns false if: + * The function returns true if: * - there is any local file not present in "old" server version files * - there is any local file missing in "old" server version files * - there is different checksum of any non-diffable file (e.g. CSV file) * - there is different content of any diffable file (e.g. GeoPackage) */ - static bool projectFilesEqual( + static bool hasLocalChanges( const QList &oldServerFiles, const QList &localFiles, const QString &projectDir