Skip to content

Commit

Permalink
code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Oct 16, 2024
1 parent 811ea5f commit 6e22121
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ;
}
}
18 changes: 15 additions & 3 deletions src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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( "/" ) ;
Expand All @@ -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 ) ;
Expand Down

0 comments on commit 6e22121

Please sign in to comment.