[libcalamaresui] Do filename checks more sanely
- check directory exists before trying to open file from it - re-use the componentDir already found for later tests.
This commit is contained in:
parent
69dabcae32
commit
1438729b72
@ -129,16 +129,16 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
, m_welcomeExpandingLogo( true )
|
||||
{
|
||||
cDebug() << "Using Calamares branding file at" << brandingFilePath;
|
||||
|
||||
QDir componentDir( componentDirectory() );
|
||||
if ( !componentDir.exists() )
|
||||
bail( "Bad component directory path." );
|
||||
|
||||
QFile file( brandingFilePath );
|
||||
if ( file.exists() && file.open( QFile::ReadOnly | QFile::Text ) )
|
||||
{
|
||||
QByteArray ba = file.readAll();
|
||||
|
||||
QFileInfo fi ( m_descriptorPath );
|
||||
QDir componentDir = fi.absoluteDir();
|
||||
if ( !componentDir.exists() )
|
||||
bail( "Bad component directory path." );
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node doc = YAML::Load( ba.constData() );
|
||||
@ -146,7 +146,7 @@ Branding::Branding( const QString& brandingFilePath,
|
||||
|
||||
m_componentName = QString::fromStdString( doc[ "componentName" ]
|
||||
.as< std::string >() );
|
||||
if ( m_componentName != QFileInfo( m_descriptorPath ).absoluteDir().dirName() )
|
||||
if ( m_componentName != componentDir.dirName() )
|
||||
bail( "The branding component name should match the name of the "
|
||||
"component directory." );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user