From 9f17d3fd1206e88485a192635a801d5575c3b26b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 9 Mar 2021 18:25:10 +0100 Subject: [PATCH] [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. --- src/libcalamaresui/utils/Paste.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/utils/Paste.cpp b/src/libcalamaresui/utils/Paste.cpp index 2d2f5404e..ea20dc8b2 100644 --- a/src/libcalamaresui/utils/Paste.cpp +++ b/src/libcalamaresui/utils/Paste.cpp @@ -12,11 +12,15 @@ #include "Branding.h" #include "DllMacro.h" #include "utils/Logger.h" +#include "utils/Units.h" #include +#include #include #include +using namespace CalamaresUtils::Units; + /** @brief Reads the logfile, returns its contents. * * Returns an empty QByteArray() on any kind of error. @@ -30,8 +34,12 @@ logFileContents() cError() << "Could not open log file"; return QByteArray(); } - // TODO: read the **last** 16kiB? - return pasteSourceFile.read( 16384 /* bytes */ ); + QFileInfo fi( pasteSourceFile ); + if ( fi.size() > 16_KiB ) + { + pasteSourceFile.seek( fi.size() - 16_KiB ); + } + return pasteSourceFile.read( 16_KiB ); }