[Pkg-owncloud-commits] [owncloud-client] 302/470: Check if the record returned from getFileRecord is valid.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu May 12 16:25:17 UTC 2016
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 d433c24186c607e73c0493be1aef1a44d451092d
Author: Klaas Freitag <freitag at owncloud.com>
Date: Mon Apr 11 12:41:26 2016 +0200
Check if the record returned from getFileRecord is valid.
Handle database fails properly.
---
src/libsync/owncloudpropagator.cpp | 12 +++++++-----
src/libsync/propagateremotemove.cpp | 16 +++++++++++-----
src/libsync/propagatorjobs.cpp | 6 ++++--
src/libsync/syncengine.cpp | 2 +-
4 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp
index 8ab6399..341cd80 100644
--- a/src/libsync/owncloudpropagator.cpp
+++ b/src/libsync/owncloudpropagator.cpp
@@ -754,11 +754,13 @@ void CleanupPollsJob::start()
auto info = _pollInfos.first();
_pollInfos.pop_front();
- SyncFileItemPtr item(new SyncFileItem(
- _journal->getFileRecord(info._file).toSyncFileItem()));
- PollJob *job = new PollJob(_account, info._url, item, _journal, _localPath, this);
- connect(job, SIGNAL(finishedSignal()), SLOT(slotPollFinished()));
- job->start();
+ SyncJournalFileRecord record = _journal->getFileRecord(info._file);
+ SyncFileItemPtr item(new SyncFileItem(record.toSyncFileItem()));
+ if (record.isValid()) {
+ PollJob *job = new PollJob(_account, info._url, item, _journal, _localPath, this);
+ connect(job, SIGNAL(finishedSignal()), SLOT(slotPollFinished()));
+ job->start();
+ }
}
void CleanupPollsJob::slotPollFinished()
diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp
index 718b337..98f4e7e 100644
--- a/src/libsync/propagateremotemove.cpp
+++ b/src/libsync/propagateremotemove.cpp
@@ -154,15 +154,21 @@ void PropagateRemoteMove::finalize()
{
SyncJournalFileRecord oldRecord =
_propagator->_journal->getFileRecord(_item->_originalFile);
+ // if reading from db failed still continue hoping that deleteFileRecord
+ // reopens the db successfully.
+ // The db is only queried to transfer the content checksum from the old
+ // to the new record. It is not a problem to skip it here.
_propagator->_journal->deleteFileRecord(_item->_originalFile);
SyncJournalFileRecord record(*_item, _propagator->getFilePath(_item->_renameTarget));
record._path = _item->_renameTarget;
- record._contentChecksum = oldRecord._contentChecksum;
- record._contentChecksumType = oldRecord._contentChecksumType;
- if (record._fileSize != oldRecord._fileSize) {
- qDebug() << "Warning: file sizes differ on server vs csync_journal: " << record._fileSize << oldRecord._fileSize;
- record._fileSize = oldRecord._fileSize; // server might have claimed different size, we take the old one from the DB
+ if (oldRecord.isValid()) {
+ record._contentChecksum = oldRecord._contentChecksum;
+ record._contentChecksumType = oldRecord._contentChecksumType;
+ if (record._fileSize != oldRecord._fileSize) {
+ qDebug() << "Warning: file sizes differ on server vs csync_journal: " << record._fileSize << oldRecord._fileSize;
+ record._fileSize = oldRecord._fileSize; // server might have claimed different size, we take the old one from the DB
+ }
}
_propagator->_journal->setFileRecord(record);
diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp
index a133b67..f137fb6 100644
--- a/src/libsync/propagatorjobs.cpp
+++ b/src/libsync/propagatorjobs.cpp
@@ -232,8 +232,10 @@ void PropagateLocalRename::start()
SyncJournalFileRecord record(*_item, targetFile);
record._path = _item->_renameTarget;
- record._contentChecksum = oldRecord._contentChecksum;
- record._contentChecksumType = oldRecord._contentChecksumType;
+ if (oldRecord.isValid()) {
+ record._contentChecksum = oldRecord._contentChecksum;
+ record._contentChecksumType = oldRecord._contentChecksumType;
+ }
if (!_item->_isDirectory) { // Directories are saved at the end
_propagator->_journal->setFileRecord(record);
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 6365ff6..a826d78 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -519,7 +519,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
// If the 'W' remote permission changed, update the local filesystem
SyncJournalFileRecord prev = _journal->getFileRecord(item->_file);
- if (prev._remotePerm.contains('W') != item->_remotePerm.contains('W')) {
+ if (prev.isValid() && prev._remotePerm.contains('W') != item->_remotePerm.contains('W')) {
const bool isReadOnly = !item->_remotePerm.contains('W');
FileSystem::setFileReadOnlyWeak(filePath, isReadOnly);
}
--
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