[Pkg-owncloud-commits] [owncloud-client] 116/219: Propagator: Don't upload files that were changed recently.

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:16 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 1f129d0bcbb6522490a871bd28edd23dc2884ed4
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Wed Sep 17 13:35:54 2014 +0200

    Propagator: Don't upload files that were changed recently.
    
    Instead skip them and try another sync later.
    
    See #2167, #2169, #2210.
---
 src/mirall/folderman.cpp       | 15 ++++++++++++---
 src/mirall/propagator_qnam.cpp | 41 +++++++++++++++++++++++++++--------------
 2 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp
index 095c33f..2df22cc 100644
--- a/src/mirall/folderman.cpp
+++ b/src/mirall/folderman.cpp
@@ -39,6 +39,15 @@ namespace Mirall {
 
 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.
+ */
+static int msBetweenRequestAndSync = 2000;
+
 FolderMan::FolderMan(QObject *parent) :
     QObject(parent),
     _syncEnabled( true )
@@ -452,9 +461,9 @@ void FolderMan::slotScheduleSync( const QString& alias )
     }
 
     // Look at the scheduleQueue in a bit to see if the sync is ready to start.
-    // The 1s delay here is essential as the sync will not upload files that were
-    // changed within the last second.
-    QTimer::singleShot(1000, this, SLOT(slotStartScheduledFolderSync()));
+    // The delay here is essential as the sync will not upload files that were
+    // changed too recently.
+    QTimer::singleShot(msBetweenRequestAndSync, this, SLOT(slotStartScheduledFolderSync()));
 }
 
 // only enable or disable foldermans will to schedule and do syncs.
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index b421b50..e604f31 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -27,6 +27,18 @@
 
 namespace Mirall {
 
+/**
+ * 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.
+ *
+ * This value must be smaller than the msBetweenRequestAndSync in
+ * the folder manager.
+ *
+ * Two seconds has shown to be a good value in tests.
+ */
+static int minFileAgeForUpload = 2000;
+
 static qint64 chunkSize() {
     static uint chunkSize;
     if (!chunkSize) {
@@ -104,7 +116,22 @@ void PropagateUploadFileQNAM::start()
         return;
     }
 
+    // Update the mtime and size, it might have changed since discovery.
+    _item._modtime = FileSystem::getModTime(_file->fileName());
     quint64 fileSize = _file->size();
+    _item._size = fileSize;
+
+    // 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) {
+        _propagator->_anotherSyncNeeded = true;
+        done(SyncFileItem::SoftError, tr("Local file changed during sync."));
+        delete _file;
+        return;
+    }
+
     _chunkCount = std::ceil(fileSize/double(chunkSize()));
     _startChunk = 0;
     _transferId = qrand() ^ _item._modtime ^ (_item._size << 16);
@@ -198,20 +225,6 @@ void PropagateUploadFileQNAM::startNextChunk()
     if (_propagator->_abortRequested.fetchAndAddRelaxed(0))
         return;
 
-
-    /*
-     *        // If the source file has changed during upload, it is detected and the
-     *        // variable _previousFileSize is set accordingly. The propagator waits a
-     *        // couple of seconds and retries.
-     *        if(_previousFileSize > 0) {
-     *            qDebug() << "File size changed underway: " << trans->stat_size - _previousFileSize;
-     *            // Report the change of the overall transmission size to the propagator
-     *            _propagator->overallTransmissionSizeChanged(qint64(trans->stat_size - _previousFileSize));
-     *            // update the item's values to the current from trans. hbf_splitlist does a stat
-     *            _item._size = trans->stat_size;
-     *            _item._modtime = trans->modtime;
-     *
-     */
     quint64 fileSize = _item._size;
     QMap<QByteArray, QByteArray> headers;
     headers["OC-Total-Length"] = QByteArray::number(fileSize);

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