From 6e221218330b6b9d484ea3a28ba9485494e552b8 Mon Sep 17 00:00:00 2001 From: mhogomchungu Date: Wed, 16 Oct 2024 07:31:49 +0300 Subject: [PATCH] code improvement --- src/main.cpp | 11 ++++------- src/utility.cpp | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 18dc8822..f580c32a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -111,14 +111,11 @@ int main( int argc,char * argv[] ) engines::enginePaths paths( ss ) ; - if( utility::platformIsWindows() ){ + if( utility::startedUpdatedVersion( ss,cargs ) ){ - if( utility::startedUpdatedVersion( ss,cargs ) ){ - - return 0 ; - } + return 0 ; + }else{ + return start( argc,argv,cargs,paths,ss ) ; } - - return start( argc,argv,cargs,paths,ss ) ; } } diff --git a/src/utility.cpp b/src/utility.cpp index 119f5d57..d034dd1d 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -1590,6 +1590,11 @@ static bool _start_updated( QProcess& exe ) bool utility::startedUpdatedVersion( settings& s,const utility::cliArguments& cargs ) { + if( utility::platformIsNOTWindows() ){ + + return false ; + } + const auto& cpath = s.configPaths() ; auto ew = cpath.endsWith( "/" ) ; @@ -1605,11 +1610,18 @@ bool utility::startedUpdatedVersion( settings& s,const utility::cliArguments& ca if( QFile::exists( update ) ){ - updated_old = update + ".old" ; + while( true ){ - if( QFile::exists( updated_old ) ){ + auto m = utility::simpleRandomNumber() ; - QDir( updated_old ).removeRecursively() ; + updated_old = update + "-" + QString::number( m ) ; + + if( QFileInfo::exists( updated_old ) ){ + + QThread::currentThread()->sleep( 1 ) ; + }else{ + break ; + } } dir.rename( update,updated_old ) ;