зеркало из https://github.com/nextcloud/desktop.git
Propagator: Upload files with future timestamps. #2880
This commit is contained in:
Родитель
842e5ba5e0
Коммит
c37792f58f
|
@ -43,8 +43,9 @@ FolderMan* FolderMan::_instance = 0;
|
||||||
* The minimum time between a sync being requested and it
|
* The minimum time between a sync being requested and it
|
||||||
* being executed in milliseconds.
|
* being executed in milliseconds.
|
||||||
*
|
*
|
||||||
* This delay must be larger than the minFileAgeForUpload in
|
* This delay must be large enough to ensure fileIsStillChanging()
|
||||||
* the propagator.
|
* in the upload propagator doesn't decide to skip the file because
|
||||||
|
* the modification was too recent.
|
||||||
*/
|
*/
|
||||||
static qint64 msBetweenRequestAndSync = 2000;
|
static qint64 msBetweenRequestAndSync = 2000;
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,23 @@
|
||||||
namespace OCC {
|
namespace OCC {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mtime of a file must be at least this many milliseconds in
|
* We do not want to upload files that are currently being modified.
|
||||||
* the past for an upload to be started. Otherwise the propagator will
|
* To avoid that, we don't upload files that have a modification time
|
||||||
* assume it's still being changed and skip it.
|
* that is too close to the current time.
|
||||||
*
|
*
|
||||||
* This value must be smaller than the msBetweenRequestAndSync in
|
* This interacts with the msBetweenRequestAndSync delay in the folder
|
||||||
* the folder manager.
|
* manager. If that delay between file-change notification and sync
|
||||||
*
|
* has passed, we should accept the file for upload here.
|
||||||
* Two seconds has shown to be a good value in tests.
|
|
||||||
*/
|
*/
|
||||||
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 qint64 chunkSize() {
|
||||||
static uint chunkSize;
|
static uint chunkSize;
|
||||||
|
@ -165,8 +172,7 @@ void PropagateUploadFileQNAM::start()
|
||||||
// But skip the file if the mtime is too close to 'now'!
|
// But skip the file if the mtime is too close to 'now'!
|
||||||
// That usually indicates a file that is still being changed
|
// That usually indicates a file that is still being changed
|
||||||
// or not yet fully copied to the destination.
|
// or not yet fully copied to the destination.
|
||||||
QDateTime modtime = Utility::qDateTimeFromTime_t(_item._modtime);
|
if (fileIsStillChanging(_item)) {
|
||||||
if (modtime.msecsTo(QDateTime::currentDateTime()) < minFileAgeForUpload) {
|
|
||||||
_propagator->_anotherSyncNeeded = true;
|
_propagator->_anotherSyncNeeded = true;
|
||||||
done(SyncFileItem::SoftError, tr("Local file changed during sync."));
|
done(SyncFileItem::SoftError, tr("Local file changed during sync."));
|
||||||
return;
|
return;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче