[libcalamares] Expand error-logging when creating files
This commit is contained in:
parent
6ef7acc108
commit
890c17cd71
@ -115,12 +115,14 @@ System::createTargetFile( const QString& path, const QByteArray& contents, Write
|
|||||||
QString completePath = targetPath( path );
|
QString completePath = targetPath( path );
|
||||||
if ( completePath.isEmpty() )
|
if ( completePath.isEmpty() )
|
||||||
{
|
{
|
||||||
|
cWarning() << "No target path for" << path;
|
||||||
return CreationResult( CreationResult::Code::Invalid );
|
return CreationResult( CreationResult::Code::Invalid );
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile f( completePath );
|
QFile f( completePath );
|
||||||
if ( ( mode == WriteMode::KeepExisting ) && f.exists() )
|
if ( ( mode == WriteMode::KeepExisting ) && f.exists() )
|
||||||
{
|
{
|
||||||
|
cWarning() << "Target file" << completePath << "already exists";
|
||||||
return CreationResult( CreationResult::Code::AlreadyExists );
|
return CreationResult( CreationResult::Code::AlreadyExists );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,13 +135,16 @@ System::createTargetFile( const QString& path, const QByteArray& contents, Write
|
|||||||
|
|
||||||
if ( !f.open( m ) )
|
if ( !f.open( m ) )
|
||||||
{
|
{
|
||||||
|
cWarning() << "Could not open target file" << completePath;
|
||||||
return CreationResult( CreationResult::Code::Failed );
|
return CreationResult( CreationResult::Code::Failed );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( f.write( contents ) != contents.size() )
|
auto written = f.write( contents );
|
||||||
|
if ( written != contents.size() )
|
||||||
{
|
{
|
||||||
f.close();
|
f.close();
|
||||||
f.remove();
|
f.remove();
|
||||||
|
cWarning() << "Short write (" << written << "out of" << contents.size() << "bytes) to" << completePath;
|
||||||
return CreationResult( CreationResult::Code::Failed );
|
return CreationResult( CreationResult::Code::Failed );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user