[Pkg-owncloud-commits] [owncloud-client] 04/20: Propagator: Use csync to get the modification time.

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Oct 24 20:08:12 UTC 2014


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

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

commit 06bcb8f3c832b673f4ccfc612152c80b03daabd0
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Thu Sep 4 11:20:41 2014 +0200

    Propagator: Use csync to get the modification time.
    
    See owncloud/core#9781
    
    (cherry picked from commit 2630a73a1c0a8dd0ca0888a35f290f08407cb039)
    
    Conflict: Move modtime comparison from socketapi.cpp to folder.cpp.
---
 src/mirall/filesystem.cpp      | 29 ++++++++++++++++++++++++++++-
 src/mirall/filesystem.h        |  8 ++++++++
 src/mirall/folder.cpp          |  5 ++++-
 src/mirall/propagator_qnam.cpp |  6 ++++--
 4 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/src/mirall/filesystem.cpp b/src/mirall/filesystem.cpp
index b317b32..7c9e000 100644
--- a/src/mirall/filesystem.cpp
+++ b/src/mirall/filesystem.cpp
@@ -12,7 +12,10 @@
  */
 
 #include "filesystem.h"
+
+#include "utility.h"
 #include <QFile>
+#include <QFileInfo>
 #include <QDebug>
 
 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
@@ -24,11 +27,16 @@
 #include <winbase.h>
 #endif
 
-
 // We use some internals of csync:
 extern "C" int c_utimes(const char *, const struct timeval *);
 extern "C" void csync_win32_set_file_hidden( const char *file, bool h );
 
+extern "C" {
+#include "vio/csync_vio_handle.h"
+#include "vio/csync_vio_file_stat.h"
+#include "vio/csync_vio_local.h"
+}
+
 namespace Mirall {
 
 bool FileSystem::fileEquals(const QString& fn1, const QString& fn2)
@@ -69,6 +77,25 @@ void FileSystem::setFileHidden(const QString& filename, bool hidden)
     return csync_win32_set_file_hidden(filename.toUtf8().constData(), hidden);
 }
 
+time_t FileSystem::getModTime(const QString &filename)
+{
+    csync_vio_file_stat_t* stat = csync_vio_file_stat_new();
+    qint64 result = -1;
+    if (csync_vio_local_stat(filename.toUtf8().data(), stat) != -1
+            && (stat->fields & CSYNC_VIO_FILE_STAT_FIELDS_MTIME))
+    {
+        result = stat->mtime;
+    }
+    else
+    {
+        qDebug() << "Could not get modification time for" << filename
+                 << "with csync, using QFileInfo";
+        result = Utility::qDateTimeToTime_t(QFileInfo(filename).lastModified());
+    }
+    csync_vio_file_stat_destroy(stat);
+    return result;
+}
+
 void FileSystem::setModTime(const QString& filename, time_t modTime)
 {
     struct timeval times[2];
diff --git a/src/mirall/filesystem.h b/src/mirall/filesystem.h
index f4a1671..4e71718 100644
--- a/src/mirall/filesystem.h
+++ b/src/mirall/filesystem.h
@@ -30,6 +30,14 @@ bool fileEquals(const QString &fn1, const QString &fn2);
 /** Mark the file as hidden  (only has effects on windows) */
 void setFileHidden(const QString& filename, bool hidden);
 
+
+/** Get the mtime for a filepath.
+ *
+ * Use this over QFileInfo::lastModified() to avoid timezone related bugs. See
+ * owncloud/core#9781 for details.
+ */
+time_t getModTime(const QString &filename);
+
 void setModTime(const QString &filename, time_t modTime);
 
 /**
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 469543a..d6fd1c8 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -27,6 +27,7 @@
 #include "mirall/clientproxy.h"
 #include "mirall/syncengine.h"
 #include "mirall/syncrunfilelog.h"
+#include "mirall/filesystem.h"
 
 #include "creds/abstractcredentials.h"
 
@@ -776,7 +777,9 @@ SyncFileStatus Folder::fileStatus( const QString& fileName )
     }
 
     // file was locally modified.
-    if( stat == FILE_STATUS_NONE && fi.lastModified() != rec._modtime ) {
+    if( stat == FILE_STATUS_NONE &&
+            FileSystem::getModTime(fi.absoluteFilePath())
+                != Utility::qDateTimeToTime_t(rec._modtime) ) {
         stat = FILE_STATUS_EVAL;
     }
 
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index dc6ea79..b5ada9a 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -302,8 +302,10 @@ void PropagateUploadFileQNAM::slotPutFinished()
             return;
         }
 
-        if (Utility::qDateTimeToTime_t(fi.lastModified()) != _item._modtime) {
-            qDebug() << "The local file has changed during upload:" << _item._modtime << "!=" << Utility::qDateTimeToTime_t(fi.lastModified())  << fi.lastModified();
+        const time_t new_mtime = FileSystem::getModTime(fi.absoluteFilePath());
+        if (new_mtime != _item._modtime) {
+            qDebug() << "The local file has changed during upload:" << _item._modtime << "!=" << new_mtime
+                     << ", QFileInfo: " << Utility::qDateTimeToTime_t(fi.lastModified()) << fi.lastModified();
             _propagator->_activeJobs--;
             done(SyncFileItem::SoftError, tr("Local file changed during sync."));
             // FIXME:  the legacy code was retrying for a few seconds.

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