[netinstall] Only wrap-up if the packages list is OK

Avoid situation where the YAML is ok but doesn't contain
a list of netinstall packages, so the packages list (the model)
is still empty.

FIXES #1673
This commit is contained in:
Adriaan de Groot 2021-04-13 16:45:01 +02:00
parent 5241e25ae8
commit 3c398bd15e
2 changed files with 17 additions and 6 deletions

View File

@ -49,10 +49,12 @@ public:
FailedNetworkError,
FailedBadData,
FailedNoData
};
/// Human-readable, translated representation of the status
QString status() const;
/// Internal code for the status
Status statusCode() const { return m_status; }
void setStatus( Status s );
bool required() const { return m_required; }

View File

@ -25,6 +25,9 @@
* On destruction, a new call to fetchNext() is queued, so that
* the queue continues loading. Calling release() before the
* destructor skips the fetchNext(), ending the queue-loading.
*
* Calling done(b) is the same as release(), **plus** done()
* is called on the queue if @p b is @c true.
*/
class FetchNextUnless
{
@ -41,6 +44,14 @@ public:
}
}
void release() { m_q = nullptr; }
void done( bool b )
{
if ( b && m_q )
{
QMetaObject::invokeMethod( m_q, "done", Qt::QueuedConnection );
}
release();
}
private:
LoaderQueue* m_q = nullptr;
@ -138,7 +149,7 @@ LoaderQueue::fetch( const QUrl& url )
void
LoaderQueue::dataArrived()
{
FetchNextUnless finished( this );
FetchNextUnless next( this );
if ( !m_reply || !m_reply->isFinished() )
{
@ -170,16 +181,14 @@ LoaderQueue::dataArrived()
if ( groups.IsSequence() )
{
finished.release();
m_config->loadGroupList( CalamaresUtils::yamlSequenceToVariant( groups ) );
emit done();
next.done( m_config->statusCode() == Config::Status::Ok );
}
else if ( groups.IsMap() )
{
finished.release();
auto map = CalamaresUtils::yamlMapToVariant( groups );
m_config->loadGroupList( map.value( "groups" ).toList() );
emit done();
next.done( m_config->statusCode() == Config::Status::Ok );
}
else
{