[libcalamaresui] Paste the last 16KiB of the log file

- If Calamares is run more than once, reading the log file
  can get you older / not relevant log messages. Get the tail
  end instead.
This commit is contained in:
Adriaan de Groot 2021-03-09 18:25:10 +01:00
parent 980e5e13f8
commit 9f17d3fd12

View File

@ -12,11 +12,15 @@
#include "Branding.h" #include "Branding.h"
#include "DllMacro.h" #include "DllMacro.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Units.h"
#include <QFile> #include <QFile>
#include <QFileInfo>
#include <QTcpSocket> #include <QTcpSocket>
#include <QUrl> #include <QUrl>
using namespace CalamaresUtils::Units;
/** @brief Reads the logfile, returns its contents. /** @brief Reads the logfile, returns its contents.
* *
* Returns an empty QByteArray() on any kind of error. * Returns an empty QByteArray() on any kind of error.
@ -30,8 +34,12 @@ logFileContents()
cError() << "Could not open log file"; cError() << "Could not open log file";
return QByteArray(); return QByteArray();
} }
// TODO: read the **last** 16kiB? QFileInfo fi( pasteSourceFile );
return pasteSourceFile.read( 16384 /* bytes */ ); if ( fi.size() > 16_KiB )
{
pasteSourceFile.seek( fi.size() - 16_KiB );
}
return pasteSourceFile.read( 16_KiB );
} }