diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index e9ecd825b..0914d8841 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 bcf8f62c3..8400c4dad 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 #ifdef Q_OS_MAC #include @@ -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 0a4c411c3..2ad23ddba 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 #include @@ -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 520b82e2c..624c83bf2 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 e0f40b57f..fce1e1cf5 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();