[Pkg-owncloud-commits] [owncloud-client] 257/333: Make the size of the log maximum 1MiB

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:17:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 2ba62b79b4d09d4a1aca9d48fb7627533abe2617
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri Mar 28 10:13:35 2014 +0100

    Make the size of the log maximum 1MiB
---
 src/mirall/syncrunfilelog.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/mirall/syncrunfilelog.cpp b/src/mirall/syncrunfilelog.cpp
index 41b1b65..eface29 100644
--- a/src/mirall/syncrunfilelog.cpp
+++ b/src/mirall/syncrunfilelog.cpp
@@ -14,6 +14,7 @@
 #include "mirall/syncrunfilelog.h"
 #include "mirall/utility.h"
 #include "mirall/mirallconfigfile.h"
+#include <qfileinfo.h>
 
 namespace Mirall {
 
@@ -78,8 +79,18 @@ QString SyncRunFileLog::instructionToStr( csync_instructions_e inst )
 
 void SyncRunFileLog::start( const Utility::StopWatch &stopWatch )
 {
+    const qint64 logfileMaxSize = 1024*1024; // 1MiB
     MirallConfigFile cfg;
-    _file.reset(new QFile(cfg.configPath() + QLatin1String("sync_log") ));
+    const QString filename = cfg.configPath() + QLatin1String("sync_log");
+
+    // When the file is too big, just rename it to an old name.
+    QFileInfo info(filename);
+    if (info.exists() && info.size() > logfileMaxSize) {
+        QString newFilename = filename + QLatin1String(".1");
+        QFile::remove(newFilename);
+        QFile::rename(filename, newFilename);
+    }
+    _file.reset(new QFile(filename));
 
     _file->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
     _out.setDevice( _file.data() );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list