From 7e706cf64654aea466c059c307e5723e2423ed5d Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:20:50 +0200 Subject: 5.6 --- lib/generate_logfile.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/generate_logfile.h') diff --git a/lib/generate_logfile.h b/lib/generate_logfile.h index 8feb696a..b54b4893 100644 --- a/lib/generate_logfile.h +++ b/lib/generate_logfile.h @@ -9,8 +9,8 @@ #include #include +#include #include -#include #include "ffs_paths.h" @@ -129,7 +129,18 @@ void saveToLastSyncsLog(const Utf8String& logstream) //throw FileError } //limit file size: 128 kB (but do not truncate new log) - newStream.resize(std::min(newStream.size(), std::max(logstream.size(), 128 * 1024))); + const size_t newSize = std::min(newStream.size(), std::max(logstream.size(), 128 * 1024)); + + //do not cut in the middle of a row + auto iter = std::search(newStream.begin() + newSize, newStream.end(), std::begin(LINE_BREAK), std::end(LINE_BREAK) - 1); + if (iter != newStream.end()) + { + newStream.resize(iter - newStream.begin()); + + newStream += LINE_BREAK; + newStream += "[...]"; + newStream += LINE_BREAK; + } saveBinStream(filename, newStream); //throw FileError } -- cgit