[Pkg-owncloud-commits] [owncloud-client] 112/219: File change detection: Also look at file sizes.
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 0eb9401c624f20a128b46f8eb1fa5a984f9ef61e
Author: Christian Kamm <kamm at incasoftware.de>
Date: Fri Sep 5 14:01:26 2014 +0200
File change detection: Also look at file sizes.
See #2167 and #2169.
* csync_detect_update: Reupload a file if the sizes differ, similar
to how we reupload if the mtimes differ.
* PropagateUploadFileQNAM::slotPutFinished(): Abort an upload if the
size changed, similar to how we abort an upload if the mtimes changed.
---
csync/src/csync_update.c | 6 ++++--
src/mirall/propagator_qnam.cpp | 10 ++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c
index 78bcbe3..3d14eb8 100644
--- a/csync/src/csync_update.c
+++ b/csync/src/csync_update.c
@@ -229,14 +229,16 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
if(tmp && tmp->phash == h ) { /* there is an entry in the database */
/* we have an update! */
- CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Database entry found, compare: %" PRId64 " <-> %" PRId64 ", etag: %s <-> %s, inode: %" PRId64 " <-> %" PRId64,
- ((int64_t) fs->mtime), ((int64_t) tmp->modtime), fs->etag, tmp->etag, (uint64_t) fs->inode, (uint64_t) tmp->inode);
+ CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "Database entry found, compare: %" PRId64 " <-> %" PRId64 ", etag: %s <-> %s, inode: %" PRId64 " <-> %" PRId64 ", size: %" PRId64 " <-> %" PRId64,
+ ((int64_t) fs->mtime), ((int64_t) tmp->modtime), fs->etag, tmp->etag, (uint64_t) fs->inode, (uint64_t) tmp->inode, (uint64_t) fs->size, (uint64_t) tmp->size);
if( !fs->etag) {
st->instruction = CSYNC_INSTRUCTION_EVAL;
goto out;
}
if((ctx->current == REMOTE_REPLICA && !c_streq(fs->etag, tmp->etag ))
|| (ctx->current == LOCAL_REPLICA && (fs->mtime != tmp->modtime
+ // zero size in statedb can happen during migration
+ || (tmp->size != 0 && fs->size != tmp->size)
#if 0
|| fs->inode != tmp->inode
#endif
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index e44d641..b421b50 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -315,8 +315,11 @@ void PropagateUploadFileQNAM::slotPutFinished()
}
const time_t new_mtime = FileSystem::getModTime(fi.absoluteFilePath());
- if (new_mtime != _item._modtime) {
- qDebug() << "The local file has changed during upload:" << _item._modtime << "!=" << new_mtime
+ const quint64 new_size = static_cast<quint64>(fi.size());
+ if (new_mtime != _item._modtime || new_size != _item._size) {
+ qDebug() << "The local file has changed during upload:"
+ << "mtime: " << _item._modtime << "<->" << new_mtime
+ << ", size: " << _item._size << "<->" << new_size
<< ", QFileInfo: " << Utility::qDateTimeToTime_t(fi.lastModified()) << fi.lastModified();
_propagator->_activeJobs--;
_propagator->_anotherSyncNeeded = true;
@@ -743,7 +746,10 @@ void PropagateDownloadFileQNAM::downloadFinished()
return;
}
+ // Maybe we downloaded a newer version of the file than we thought we would...
+ // Get up to date information for the journal.
FileSystem::setModTime(fn, _item._modtime);
+ _item._size = existingFile.size();
_propagator->_journal->setFileRecord(SyncJournalFileRecord(_item, fn));
_propagator->_journal->setDownloadInfo(_item._file, SyncJournalDb::DownloadInfo());
--
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