[Pkg-owncloud-commits] [owncloud-client] 381/484: owncloudcmd: Don't do a check that file are older than 2s (#4160)

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:38:09 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 00202118576f35c6fb2059476849bbb541d910e7
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri Nov 20 15:14:22 2015 +0100

    owncloudcmd:  Don't do a check that file are older than 2s (#4160)
    
    This is required for the smashbox test to pass
---
 src/cmd/cmd.cpp                 |  7 +++++--
 src/gui/folderman.cpp           | 13 ++-----------
 src/libsync/propagateupload.cpp |  3 ++-
 src/libsync/syncengine.cpp      |  2 ++
 src/libsync/syncengine.h        |  7 +++++++
 5 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp
index e9ecd82..0914d88 100644
--- a/src/cmd/cmd.cpp
+++ b/src/cmd/cmd.cpp
@@ -296,7 +296,7 @@ int main(int argc, char **argv) {
     if(!options.target_url.endsWith("/")) {
         options.target_url.append("/");
     }
-   
+
     if( options.nonShib ) {
         account->setNonShib(true);
     }
@@ -304,7 +304,7 @@ int main(int argc, char **argv) {
     if(!options.davPath.isEmpty()) {
         account->setDavPath( options.davPath );
     }
- 
+
     if( !options.target_url.contains( account->davPath() )) {
         options.target_url.append(account->davPath());
     }
@@ -379,6 +379,9 @@ int main(int argc, char **argv) {
     account->setCredentials(cred);
     account->setSslErrorHandler(sslErrorHandler);
 
+    // much lower age than the default since this utility is usually made to be run right after a change in the tests
+    SyncEngine::minimumFileAgeForUpload = 0;
+
     int restartCount = 0;
 restart_sync:
 
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp
index bcf8f62..8400c4d 100644
--- a/src/gui/folderman.cpp
+++ b/src/gui/folderman.cpp
@@ -22,6 +22,7 @@
 #include "accountstate.h"
 #include "accountmanager.h"
 #include "filesystem.h"
+#include <syncengine.h>
 
 #ifdef Q_OS_MAC
 #include <CoreServices/CoreServices.h>
@@ -40,16 +41,6 @@ namespace OCC {
 
 FolderMan* FolderMan::_instance = 0;
 
-/**
- * The minimum time between a sync being requested and it
- * being executed in milliseconds.
- *
- * 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;
-
 FolderMan::FolderMan(QObject *parent) :
     QObject(parent),
     _currentSyncFolder(0),
@@ -652,7 +643,7 @@ void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
 
     // A minimum of delay here is essential as the sync will not upload
     // files that were changed too recently.
-    msDelay = qMax(msBetweenRequestAndSync, msDelay);
+    msDelay = qMax(SyncEngine::minimumFileAgeForUpload, msDelay);
 
     qDebug() << "Scheduling a sync in" << (msDelay/1000) << "seconds";
     _startScheduledSyncTimer.start(msDelay);
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index 0a4c411..2ad23dd 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -23,6 +23,7 @@
 #include "filesystem.h"
 #include "propagatorjobs.h"
 #include "transmissionchecksumvalidator.h"
+#include "syncengine.h"
 
 #include <json.h>
 #include <QNetworkAccessManager>
@@ -53,7 +54,7 @@ static bool fileIsStillChanging(const SyncFileItem & item)
     const QDateTime modtime = Utility::qDateTimeFromTime_t(item._modtime);
     const qint64 msSinceMod = modtime.msecsTo(QDateTime::currentDateTime());
 
-    return msSinceMod < 2000
+    return msSinceMod < SyncEngine::minimumFileAgeForUpload
             // if the mtime is too much in the future we *do* upload the file
             && msSinceMod > -10000;
 }
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 520b82e..624c83b 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -54,6 +54,8 @@ namespace OCC {
 
 bool SyncEngine::_syncRunning = false;
 
+qint64 SyncEngine::minimumFileAgeForUpload = 2000;
+
 SyncEngine::SyncEngine(AccountPtr account, CSYNC *ctx, const QString& localPath,
                        const QString& remoteURL, const QString& remotePath, OCC::SyncJournalDb* journal)
   : _account(account)
diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h
index e0f40b5..fce1e1c 100644
--- a/src/libsync/syncengine.h
+++ b/src/libsync/syncengine.h
@@ -88,6 +88,13 @@ public:
     AccountPtr account() const;
     SyncJournalDb *journal() const { return _journal; }
 
+    /**
+     * Minimum age, in milisecond, of a file that can be uploaded.
+     * Files more recent than that are not going to be uploaeded as they are considered
+     * too young and possibly still changing
+     */
+    static qint64 minimumFileAgeForUpload; // in ms
+
 signals:
     void csyncError( const QString& );
     void csyncUnavailable();

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