diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index c074b7403..74fd94a6e 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -153,7 +153,7 @@ uploadServerFromMap( const QVariantMap& map ) QString typestring = map[ "type" ].toString(); QString urlstring = map[ "url" ].toString(); - qint64 sizeLimit = map[ "sizeLimit" ].toLongLong(); + qint64 sizeLimitKiB = map[ "sizeLimit" ].toLongLong(); if ( typestring.isEmpty() || urlstring.isEmpty() ) { @@ -163,7 +163,7 @@ uploadServerFromMap( const QVariantMap& map ) bool bogus = false; // we don't care about type-name lookup success here return Branding::UploadServerInfo( names.find( typestring, bogus ), QUrl( urlstring, QUrl::ParsingMode::StrictMode ), - sizeLimit ); + sizeLimitKiB ); } /** @brief Load the @p map with strings from @p config diff --git a/src/libcalamaresui/utils/Paste.cpp b/src/libcalamaresui/utils/Paste.cpp index 6d2142626..56c944bd4 100644 --- a/src/libcalamaresui/utils/Paste.cpp +++ b/src/libcalamaresui/utils/Paste.cpp @@ -30,8 +30,10 @@ using namespace CalamaresUtils::Units; * Returns an empty QByteArray() on any kind of error. */ STATICTEST QByteArray -logFileContents( qint64 sizeLimit ) +logFileContents( qint64 sizeLimitKiB ) { + if( sizeLimitKiB == 0 ) + return QByteArray(); const QString name = Logger::logFile(); QFile pasteSourceFile( name ); if ( !pasteSourceFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) @@ -40,15 +42,16 @@ logFileContents( qint64 sizeLimit ) return QByteArray(); } QFileInfo fi( pasteSourceFile ); - sizeLimit = ( sizeLimit < 0 ) ? 1024*1024 : sizeLimit * 1024; //For KiB to bytes - cDebug() << "Log upload size limit was set to " << sizeLimit << " bytes"; - if ( fi.size() > sizeLimit and sizeLimit > 0 ) + if( sizeLimitKiB < 0 ) + sizeLimitKiB = 1024; + qint64 sizeLimitBytes = CalamaresUtils::KiBtoBytes( ( unsigned long long ) sizeLimitKiB ); + cDebug() << "Log upload size limit was set to" << sizeLimitKiB << "KiB"; + if ( fi.size() > sizeLimitBytes and sizeLimitBytes > 0 ) { - // Fixme : this following line is not getting pasted - cDebug() << "Only last " << sizeLimit << " bytes of log file (" << fi.size() << ") uploaded" ; - pasteSourceFile.seek( fi.size() - sizeLimit ); + cDebug() << "Only last" << sizeLimitBytes << "bytes of log file (sized" << fi.size() << "bytes) uploaded" ; + pasteSourceFile.seek( fi.size() - sizeLimitBytes + 1_KiB ); } - return pasteSourceFile.read( sizeLimit ); + return pasteSourceFile.read( sizeLimitBytes + 1_KiB ); }