[Pkg-owncloud-commits] [owncloud-client] 65/164: Propagator: Upload files with future timestamps. #2880

Sandro Knauß hefee-guest at moszumanska.debian.org
Sun Mar 22 11:56:54 UTC 2015


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 c37792f58fd396a8cd5e66d7249314ed40dba558
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Thu Feb 26 11:00:06 2015 +0100

    Propagator: Upload files with future timestamps. #2880
---
 src/gui/folderman.cpp           |  5 +++--
 src/libsync/propagateupload.cpp | 26 ++++++++++++++++----------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp
index 853fef2..f401020 100644
--- a/src/gui/folderman.cpp
+++ b/src/gui/folderman.cpp
@@ -43,8 +43,9 @@ FolderMan* FolderMan::_instance = 0;
  * The minimum time between a sync being requested and it
  * being executed in milliseconds.
  *
- * This delay must be larger than the minFileAgeForUpload in
- * the propagator.
+ * This delay must be large enough to ensure fileIsStillChanging()
+ * in the upload propagator doesn't decide to skip the file because
+ * the modification was too recent.
  */
 static qint64 msBetweenRequestAndSync = 2000;
 
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index f3a6c0d..c3f50f3 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -31,16 +31,23 @@
 namespace OCC {
 
 /**
- * The mtime of a file must be at least this many milliseconds in
- * the past for an upload to be started. Otherwise the propagator will
- * assume it's still being changed and skip it.
+ * We do not want to upload files that are currently being modified.
+ * To avoid that, we don't upload files that have a modification time
+ * that is too close to the current time.
  *
- * This value must be smaller than the msBetweenRequestAndSync in
- * the folder manager.
- *
- * Two seconds has shown to be a good value in tests.
+ * This interacts with the msBetweenRequestAndSync delay in the folder
+ * manager. If that delay between file-change notification and sync
+ * has passed, we should accept the file for upload here.
  */
-static int minFileAgeForUpload = 2000;
+static bool fileIsStillChanging(const SyncFileItem & item)
+{
+    const QDateTime modtime = Utility::qDateTimeFromTime_t(item._modtime);
+    const qint64 msSinceMod = modtime.msecsTo(QDateTime::currentDateTime());
+
+    return msSinceMod < 2000
+            // if the mtime is too much in the future we *do* upload the file
+            && msSinceMod > -10000;
+}
 
 static qint64 chunkSize() {
     static uint chunkSize;
@@ -165,8 +172,7 @@ void PropagateUploadFileQNAM::start()
     // But skip the file if the mtime is too close to 'now'!
     // That usually indicates a file that is still being changed
     // or not yet fully copied to the destination.
-    QDateTime modtime = Utility::qDateTimeFromTime_t(_item._modtime);
-    if (modtime.msecsTo(QDateTime::currentDateTime()) < minFileAgeForUpload) {
+    if (fileIsStillChanging(_item)) {
         _propagator->_anotherSyncNeeded = true;
         done(SyncFileItem::SoftError, tr("Local file changed during sync."));
         return;

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