|
|
|
@ -33,10 +33,16 @@ using namespace CalamaresUtils::Units;
|
|
|
|
|
STATICTEST QByteArray
|
|
|
|
|
logFileContents( const qint64 sizeLimitBytes )
|
|
|
|
|
{
|
|
|
|
|
if ( sizeLimitBytes != -1 )
|
|
|
|
|
if ( sizeLimitBytes > 0 )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "Log upload size limit was limited to" << sizeLimitBytes << "bytes";
|
|
|
|
|
}
|
|
|
|
|
if ( sizeLimitBytes == 0 )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "Log upload size is 0, upload disabled.";
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString name = Logger::logFile();
|
|
|
|
|
QFile pasteSourceFile( name );
|
|
|
|
|
if ( !pasteSourceFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
|
|
|
@ -44,7 +50,7 @@ logFileContents( const qint64 sizeLimitBytes )
|
|
|
|
|
cWarning() << "Could not open log file" << name;
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
if ( sizeLimitBytes == -1 )
|
|
|
|
|
if ( sizeLimitBytes < 0 )
|
|
|
|
|
{
|
|
|
|
|
return pasteSourceFile.readAll();
|
|
|
|
|
}
|
|
|
|
@ -52,7 +58,7 @@ logFileContents( const qint64 sizeLimitBytes )
|
|
|
|
|
if ( fi.size() > sizeLimitBytes )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "Only last" << sizeLimitBytes << "bytes of log file (sized" << fi.size() << "bytes) uploaded";
|
|
|
|
|
fi.refresh();
|
|
|
|
|
fi.refresh(); // Because we just wrote to the file with that cDebug() ^^
|
|
|
|
|
pasteSourceFile.seek( fi.size() - sizeLimitBytes );
|
|
|
|
|
}
|
|
|
|
|
return pasteSourceFile.read( sizeLimitBytes );
|
|
|
|
@ -115,7 +121,7 @@ CalamaresUtils::Paste::doLogUpload( QObject* parent )
|
|
|
|
|
auto [ type, serverUrl, sizeLimitBytes ] = Calamares::Branding::instance()->uploadServer();
|
|
|
|
|
if ( !serverUrl.isValid() )
|
|
|
|
|
{
|
|
|
|
|
cWarning() << "Upload configure with invalid URL";
|
|
|
|
|
cWarning() << "Upload configured with invalid URL";
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
if ( type == Calamares::Branding::UploadServerType::None )
|
|
|
|
@ -123,6 +129,12 @@ CalamaresUtils::Paste::doLogUpload( QObject* parent )
|
|
|
|
|
// Early return to avoid reading the log file
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
if ( sizeLimitBytes == 0 )
|
|
|
|
|
{
|
|
|
|
|
// Suggests that it is un-set in the config file
|
|
|
|
|
cWarning() << "Upload configured to send 0 bytes";
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray pasteData = logFileContents( sizeLimitBytes );
|
|
|
|
|
if ( pasteData.isEmpty() )
|
|
|
|
@ -181,5 +193,5 @@ bool
|
|
|
|
|
CalamaresUtils::Paste::isEnabled()
|
|
|
|
|
{
|
|
|
|
|
auto [ type, serverUrl, sizeLimitBytes ] = Calamares::Branding::instance()->uploadServer();
|
|
|
|
|
return type != Calamares::Branding::UploadServerType::None;
|
|
|
|
|
return type != Calamares::Branding::UploadServerType::None && sizeLimitBytes != 0;
|
|
|
|
|
}
|
|
|
|
|