From f09076180d0aff86cf6fcb32cade8d2409230c75 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 2 Apr 2014 16:18:09 +0200 Subject: [PATCH] don't add the list of field on the log for every sync --- src/mirall/syncrunfilelog.cpp | 23 ++++++++++++----------- src/mirall/syncrunfilelog.h | 1 - 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mirall/syncrunfilelog.cpp b/src/mirall/syncrunfilelog.cpp index eface2909..894275924 100644 --- a/src/mirall/syncrunfilelog.cpp +++ b/src/mirall/syncrunfilelog.cpp @@ -85,7 +85,9 @@ void SyncRunFileLog::start( const Utility::StopWatch &stopWatch ) // When the file is too big, just rename it to an old name. QFileInfo info(filename); - if (info.exists() && info.size() > logfileMaxSize) { + bool exists = info.exists(); + if (exists && info.size() > logfileMaxSize) { + exists = false; QString newFilename = filename + QLatin1String(".1"); QFile::remove(newFilename); QFile::rename(filename, newFilename); @@ -98,9 +100,17 @@ void SyncRunFileLog::start( const Utility::StopWatch &stopWatch ) QDateTime dt = stopWatch.startTime(); QDateTime de = stopWatch.timeOfLap(QLatin1String("Sync Finished")); + if (!exists) { + // We are creating a new file, add the note. + _out << "# timestamp | duration | file | instruction | modtime | etag | " + "size | fileId | status | errorString | http result code | " + "other size | other modtime | other etag | other fileId | " + "other instruction" << endl; + } + + _out << "#=#=#=# Syncrun started " << dateTimeStr(dt) << " until " << dateTimeStr(de) << " (" << stopWatch.durationOfLap(QLatin1String("Sync Finished")) << " msec)" << endl; - _start = true; } void SyncRunFileLog::logItem( const SyncFileItem& item ) @@ -110,15 +120,6 @@ void SyncRunFileLog::logItem( const SyncFileItem& item ) return; } - // log a list of fields if the log really adds lines. - if( _start ) { - _out << "# timestamp | duration | file | instruction | modtime | etag | " - "size | fileId | status | errorString | http result code | " - "other size | other modtime | other etag | other fileId | " - "other instruction" << endl; - _start = false; - } - const QChar L = QLatin1Char('|'); _out << item._responseTimeStamp << L; _out << QString::number(item._requestDuration) << L; diff --git a/src/mirall/syncrunfilelog.h b/src/mirall/syncrunfilelog.h index 161d26d6f..ae70bd2fd 100644 --- a/src/mirall/syncrunfilelog.h +++ b/src/mirall/syncrunfilelog.h @@ -40,7 +40,6 @@ private: QScopedPointer _file; QTextStream _out; - bool _start; }; }