diff --git a/src/checkforupdates.cpp b/src/checkforupdates.cpp index 2dad1368..67f1771b 100644 --- a/src/checkforupdates.cpp +++ b/src/checkforupdates.cpp @@ -264,7 +264,7 @@ void checkUpdates::networkReply( int position, checkforupdateswindow::args args ; - args.engineName = s.known() ? s.name() : "SiriKali" ; ; + args.engineName = s.known() ? s.name() : "SiriKali" ; auto ss = QString::number( m_timeOut / 1000 ) ; args.error = QObject::tr( "Network Request Failed To Respond Within %1 Seconds." ).arg( ss ) ; diff --git a/src/checkforupdateswindow.cpp b/src/checkforupdateswindow.cpp index b32ad617..fb27f9d3 100644 --- a/src/checkforupdateswindow.cpp +++ b/src/checkforupdateswindow.cpp @@ -105,7 +105,7 @@ void checkforupdateswindow::add( const checkforupdateswindow::args& e ) { auto txt = e.engineName ; - m_opts.emplace_back( e.data,e.engineName ) ; + m_opts.emplace_back( e.data,e.engineName,e.error.isEmpty() ) ; if( e.error.isEmpty() ){ @@ -251,7 +251,29 @@ void checkforupdateswindow::currentItemChanged( QTableWidgetItem * c, QTableWidg void checkforupdateswindow::tableUpdate( int row,const QString& s ) { - m_ui->tableWidget->item( row,0 )->setText( s ) ; + if( m_opts[ row ].noError() ){ + + m_ui->tableWidget->item( row,0 )->setText( s ) ; + } +} + +QString checkforupdateswindow::archiveName( int row ) +{ + if( m_opts[ row ].name() == "Securefs" ){ + + if( utility::platformIsLinux() ){ + + return "securefs-linux-amd64-release.zip" ; + + }else if( utility::platformIsWindows() ){ + + return "securefs-windows-amd64-release.zip" ; + }else{ + return "securefs-macos-amd64-release.zip" ; + } + }else{ + return "linux-static_amd64.tar.gz" ; + } } QString checkforupdateswindow::tableText( int row ) @@ -420,39 +442,28 @@ void checkforupdateswindow::extracted( Ctx ctx,const utils::qprocess::outPut& p void checkforupdateswindow::update( int row ) { - const auto array = m_opts[ row ].data().value( "assets" ).toArray() ; - - QString name ; + if( m_opts[ row ].noError() ){ - if( m_opts[ row ].name() == "Securefs" ){ + const auto array = m_opts[ row ].data().value( "assets" ).toArray() ; - if( utility::platformIsLinux() ){ + auto name = this->archiveName( row ) ; - name = "securefs-linux-amd64-release.zip" ; + for( const auto& it : array ){ - }else if( utility::platformIsWindows() ){ - - name = "securefs-windows-amd64-release.zip" ; - }else{ - name = "securefs-macos-amd64-release.zip" ; - } - }else{ - name = "linux-static_amd64.tar.gz" ; - } + auto obj = it.toObject() ; - for( const auto& it : array ){ + auto url = obj.value( "browser_download_url" ).toString() ; - auto obj = it.toObject() ; + if( url.endsWith( name ) ){ - auto url = obj.value( "browser_download_url" ).toString() ; + return this->download( row,url,name ) ; + } + } - if( url.endsWith( name ) ){ + auto mm = tr( "Failed To Find Archive To Download" ) ; - return this->download( row,url,name ) ; - } + this->tableUpdate( row,tr( "Error" ) + "\n" + mm ) ; } - - this->tableUpdate( row,tr( "Error" ) + "\n" + tr( "Failed To Find Archive To Download" ) ) ; } void checkforupdateswindow::closeEvent( QCloseEvent * e ) diff --git a/src/checkforupdateswindow.h b/src/checkforupdateswindow.h index c060af4e..cca1e14f 100644 --- a/src/checkforupdateswindow.h +++ b/src/checkforupdateswindow.h @@ -120,6 +120,7 @@ class checkforupdateswindow : public QDialog void extracted( Ctx,const utils::qprocess::outPut& ) ; void currentItemChanged( QTableWidgetItem * ,QTableWidgetItem * ) ; void tableUpdate( int,const QString& ) ; + QString archiveName( int ) ; QString tableText( int ) ; QString exePath( int ) ; QString exeName( int ) ; @@ -135,8 +136,8 @@ class checkforupdateswindow : public QDialog class opts { public: - opts( const QJsonObject& s,const QString& m ) : - m_data( s ),m_name( m ) + opts( const QJsonObject& s,const QString& m,bool e ) : + m_data( s ),m_name( m ),m_noError( e ) { } const QJsonObject& data() const @@ -147,9 +148,14 @@ class checkforupdateswindow : public QDialog { return m_name ; } + bool noError() const + { + return m_noError ; + } private: QJsonObject m_data ; QString m_name ; + bool m_noError ; } ; class locale