Skip to content

Commit

Permalink
CU-861n8yh4d Show migration dialogue (if needed) only once
Browse files Browse the repository at this point in the history
  • Loading branch information
iiLubos committed Sep 19, 2023
1 parent 4f2dbab commit 5fbb7c9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
44 changes: 30 additions & 14 deletions core/merginapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,14 +1347,8 @@ void MerginApi::checkMerginVersion( QString apiVersion, bool serverSupportsSubsc
{
int major = -1;
int minor = -1;
QRegularExpression re;
re.setPattern( QStringLiteral( "(?<major>\\d+)[.](?<minor>\\d+)" ) );
QRegularExpressionMatch match = re.match( apiVersion );
if ( match.hasMatch() )
{
major = match.captured( "major" ).toInt();
minor = match.captured( "minor" ).toInt();
}

parseVersion( apiVersion, major, minor );

if ( ( MERGIN_API_VERSION_MAJOR == major && MERGIN_API_VERSION_MINOR <= minor ) || ( MERGIN_API_VERSION_MAJOR < major ) )
{
Expand All @@ -1364,12 +1358,6 @@ void MerginApi::checkMerginVersion( QString apiVersion, bool serverSupportsSubsc
{
setApiVersionStatus( MerginApiStatus::INCOMPATIBLE );
}

// will be dropped support for old servers (mostly CE servers without workspaces)
if ( ( MINIMUM_SERVER_VERSION_MAJOR == major && MINIMUM_SERVER_VERSION_MINOR > minor ) || ( MINIMUM_SERVER_VERSION_MAJOR > major ) )
{
emit migrationRequested();
}
}
else
{
Expand Down Expand Up @@ -1480,6 +1468,21 @@ ProjectDiff MerginApi::localProjectChanges( const QString &projectDir )
return compareProjectFiles( projectMetadata.files, projectMetadata.files, localFiles, projectDir, config.isValid, config );
}

bool MerginApi::parseVersion( const QString &version, int &major, int &minor )
{
QRegularExpression re;
re.setPattern( QStringLiteral( "(?<major>\\d+)[.](?<minor>\\d+)" ) );
QRegularExpressionMatch match = re.match( version );
if ( match.hasMatch() )
{
major = match.captured( "major" ).toInt();
minor = match.captured( "minor" ).toInt();
return true;
}

return false;
}

QString MerginApi::getTempProjectDir( const QString &projectFullName )
{
return mDataDir + "/" + TEMP_FOLDER + projectFullName;
Expand Down Expand Up @@ -3361,6 +3364,19 @@ void MerginApi::getServerConfigReplyFinished()
{
setServerType( MerginServerType::SAAS );
}

// parse server version
QString apiVersion = doc.object().value( QStringLiteral( "version" ) ).toString();
int major = -1;
int minor = -1;

parseVersion( apiVersion, major, minor );

// will be dropped support for old servers (mostly CE servers without workspaces)
if ( ( MINIMUM_SERVER_VERSION_MAJOR == major && MINIMUM_SERVER_VERSION_MINOR > minor ) || ( MINIMUM_SERVER_VERSION_MAJOR > major ) )
{
emit migrationRequested();
}
}
}
else
Expand Down
9 changes: 9 additions & 0 deletions core/merginapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ class MerginApi: public QObject

static ProjectDiff localProjectChanges( const QString &projectDir );

/**
* Parse major and minor version number from version string
* \param version full server version string
* \param major parsed major number
* \param minor parsed minor number
* @return true when parsing was successful
*/
static bool parseVersion( const QString &version, int &major, int &minor );

/**
* Finds project in merginProjects list according its full name.
* \param projectPath Full path to project's folder
Expand Down

1 comment on commit 5fbb7c9

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.09.456911 just submitted!

Please sign in to comment.