[Pkg-owncloud-commits] [owncloud-client] 54/103: Propagator: Add makeConflictFileName function

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Apr 30 18:08:59 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 4be20db670bbda46678de7d762598b9971f3e4fe
Author: Markus Goetz <markus at woboq.com>
Date:   Tue Apr 22 16:07:01 2014 +0200

    Propagator: Add makeConflictFileName function
---
 src/mirall/propagator_legacy.cpp | 12 +++---------
 src/mirall/propagator_qnam.cpp   | 24 +++++++++++++++---------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/mirall/propagator_legacy.cpp b/src/mirall/propagator_legacy.cpp
index 2aeada2..d3d9498 100644
--- a/src/mirall/propagator_legacy.cpp
+++ b/src/mirall/propagator_legacy.cpp
@@ -437,6 +437,8 @@ void PropagateDownloadFileLegacy::notify_status_cb(void* userdata, ne_session_st
     }
 }
 
+extern QString makeConflictFileName(QString &fn, QDateTime dt); // _qnam.cpp
+
 void PropagateDownloadFileLegacy::start()
 {
     if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
@@ -564,15 +566,7 @@ void PropagateDownloadFileLegacy::start()
     //In case of conflict, make a backup of the old file
     if (isConflict) {
         QFile f(fn);
-        QString conflictFileName(fn);
-        // Add _conflict-XXXX  before the extention.
-        int dotLocation = conflictFileName.lastIndexOf('.');
-        // If no extention, add it at the end  (take care of cases like foo/.hidden or foo.bar/file)
-        if (dotLocation <= conflictFileName.lastIndexOf('/') + 1) {
-            dotLocation = conflictFileName.size();
-        }
-        QString timeString = Utility::qDateTimeFromTime_t(_item._modtime).toString("yyyyMMdd-hhmmss");
-        conflictFileName.insert(dotLocation, "_conflict-" + timeString);
+        QString conflictFileName = makeConflictFileName(fn, Utility::qDateTimeFromTime_t(_item._modtime));
         if (!f.rename(conflictFileName)) {
             //If the rename fails, don't replace it.
             done(SyncFileItem::NormalError, f.errorString());
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 800fad2..4365154 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -524,6 +524,20 @@ void PropagateDownloadFileQNAM::slotGetFinished()
     downloadFinished();
 }
 
+QString makeConflictFileName(QString &fn, QDateTime dt)
+{
+    QString conflictFileName(fn);
+    // Add _conflict-XXXX  before the extention.
+    int dotLocation = conflictFileName.lastIndexOf('.');
+    // If no extention, add it at the end  (take care of cases like foo/.hidden or foo.bar/file)
+    if (dotLocation <= conflictFileName.lastIndexOf('/') + 1) {
+        dotLocation = conflictFileName.size();
+    }
+    QString timeString = dt.toString("yyyyMMdd-hhmmss");
+    conflictFileName.insert(dotLocation, "_conflict-" + timeString);
+    return conflictFileName;
+}
+
 void PropagateDownloadFileQNAM::downloadFinished()
 {
 
@@ -535,15 +549,7 @@ void PropagateDownloadFileQNAM::downloadFinished()
     //In case of conflict, make a backup of the old file
     if (isConflict) {
         QFile f(fn);
-        QString conflictFileName(fn);
-        // Add _conflict-XXXX  before the extention.
-        int dotLocation = conflictFileName.lastIndexOf('.');
-        // If no extention, add it at the end  (take care of cases like foo/.hidden or foo.bar/file)
-        if (dotLocation <= conflictFileName.lastIndexOf('/') + 1) {
-            dotLocation = conflictFileName.size();
-        }
-        QString timeString = Utility::qDateTimeFromTime_t(_item._modtime).toString("yyyyMMdd-hhmmss");
-        conflictFileName.insert(dotLocation, "_conflict-" + timeString);
+        QString conflictFileName = makeConflictFileName(fn, Utility::qDateTimeFromTime_t(_item._modtime));
         if (!f.rename(conflictFileName)) {
             //If the rename fails, don't replace it.
             done(SyncFileItem::NormalError, f.errorString());

-- 
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