mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-25 16:38:21 -04:00
[libcalamares] Expand error-logging when creating files
This commit is contained in:
parent
6ef7acc108
commit
890c17cd71
1 changed files with 6 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue