Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Dec 26, 2024
1 parent cb4afdf commit 59ef213
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/checkforupdates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void checkUpdates::checkIfInstalled()
{
auto& s = settings::instance() ;

auto m = s.internallyManageBackEnds() && utility::canDownload() ;
auto m = s.internallyManageBackEnds() ;

QStringList apps ;

Expand Down
4 changes: 2 additions & 2 deletions src/engines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,9 +1103,9 @@ bool engines::engine::windowsCanUnlocInReadWriteMode() const
return m_Options.windowsCanUnlockInReadWriteMode ;
}

bool engines::engine::updatable( bool s ) const
bool engines::engine::updatable( bool ) const
{
return s ;
return false ;
}

bool engines::engine::isInstalled() const
Expand Down
15 changes: 12 additions & 3 deletions src/engines/cryptomator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ bool cryptomator::updatable( bool s ) const
{
if( utility::platformIsFlatPak() ){

return true ;
return utility::archInUseIsAnyOf( utility::arch::x64,utility::arch::aarch64 ) ;

}else if( s ){

if( utility::platformIsWindows() ){

return true ;
return utility::archInUse( utility::arch::x64 ) ;
}else{
return false ;
}
Expand Down Expand Up @@ -134,7 +134,16 @@ bool cryptomator::onlineArchiveFileName( const QString& e ) const
{
if( utility::platformIsLinux() ){

return e.endsWith( "linux-x64.zip" ) ;
if( utility::archInUse( utility::arch::x64 ) ){

return e.endsWith( "linux-x64.zip" ) ;

}else if( utility::archInUse( utility::arch::aarch64 ) ){

return e.endsWith( "linux-aarch64.zip" ) ;
}else{
return false ;
}

}else if( utility::platformIsWindows() ){

Expand Down
4 changes: 2 additions & 2 deletions src/engines/gocryptfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ bool gocryptfs::updatable( bool s ) const

return false ;

}else if( utility::canDownload() ){
}else if( utility::platformIsLinux() ){

return utility::platformIsLinux() ;
return utility::archInUse( utility::arch::x64 ) ;
}else{
return false ;
}
Expand Down
6 changes: 1 addition & 5 deletions src/engines/securefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,8 @@ bool securefs::updatable( bool s ) const
if( utility::platformIsFlatPak() ){

return false ;

}else if( utility::canDownload( utility::arch::x64 ) ){

return utility::platformIsLinux() || utility::platformIsWindows() ;
}else{
return false ;
return utility::archInUseIsAnyOf( utility::arch::x64 ) ;
}
}else{
return false ;
Expand Down
27 changes: 18 additions & 9 deletions src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1739,23 +1739,32 @@ bool utility::copyFile( const QString& s,const QString& d,bool setExePermssion )
return false ;
}

bool utility::canDownload( utility::arch arch )
static QString _currentCpuArch()
{
#if QT_VERSION < QT_VERSION_CHECK( 5,4,0 )

return false ;
return {} ;
#else
auto m = QSysInfo::currentCpuArchitecture() ;
return QSysInfo::currentCpuArchitecture() ;
#endif
}

bool utility::archInUse( utility::arch m )
{
auto e = _currentCpuArch() ;

if( m == utility::arch::x64 ){

return e == "x86_64";

if( arch == utility::arch::either ){
}else if( m == utility::arch::x86 ){

return m == "x86_64" || m == "i386" ;
return e == "i386" ;

}else if( arch == utility::arch::x64 ){
}else if( m == utility::arch::aarch64 ){

return m == "x86_64" ;
return e == "arm64" ;
}else{
return m == "i386" ;
return false ;
}
#endif
}
18 changes: 16 additions & 2 deletions src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,23 @@ namespace utility

void applicationStarted() ;

enum class arch{ x64,x86,either } ;
enum class arch{ x64,x86,aarch64 } ;

bool canDownload( utility::arch = utility::arch::either ) ;
bool archInUse( utility::arch ) ;

template< typename ... T >
bool archInUseIsAnyOf( T ... m )
{
for( const auto& it : { m ... } ){

if( utility::archInUse( it ) ){

return true ;
}
}

return false ;
}

QString removeOption( const QStringList&,const QString& option ) ;
QString removeOption( const QString& commaSeparatedString,const QString& option ) ;
Expand Down

0 comments on commit 59ef213

Please sign in to comment.