[Pkg-owncloud-commits] [owncloud-client] 295/470: Handle setFileRecord errors #4632

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu May 12 16:25:16 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 6ee7e82913ab66b319357539869e4eb7c426a1c4
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Thu Apr 7 11:47:04 2016 +0200

    Handle setFileRecord errors #4632
---
 src/libsync/owncloudpropagator.cpp   | 20 +++++++++++++++++---
 src/libsync/propagatedownload.cpp    |  5 ++++-
 src/libsync/propagateremotemkdir.cpp |  5 ++++-
 src/libsync/propagateremotemove.cpp  |  5 ++++-
 src/libsync/propagateupload.cpp      |  8 ++++++--
 src/libsync/propagatorjobs.cpp       | 10 ++++++++--
 6 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp
index 8ab6399..bc1f125 100644
--- a/src/libsync/owncloudpropagator.cpp
+++ b/src/libsync/owncloudpropagator.cpp
@@ -707,6 +707,7 @@ void PropagateDirectory::slotSubJobFinished(SyncFileItem::Status status)
 
 void PropagateDirectory::finalize()
 {
+    bool ok = true;
     if (!_item->isEmpty() && _hasError == SyncFileItem::NoStatus) {
         if( !_item->_renameTarget.isEmpty() ) {
             _item->_file = _item->_renameTarget;
@@ -720,13 +721,20 @@ void PropagateDirectory::finalize()
                 }
             }
             SyncJournalFileRecord record(*_item,  _propagator->_localDir + _item->_file);
-            _propagator->_journal->setFileRecordMetadata(record);
+            ok = _propagator->_journal->setFileRecordMetadata(record);
+            if (!ok) {
+                _item->_status = SyncFileItem::FatalError;
+                _item->_errorString = tr("Error writing metadata to the database");
+                qWarning() << "Error writing to the database for file" << _item->_file;
+            }
         }
     }
     _state = Finished;
     // Just to make sure that the SocketApi will know by looking in
     // SyncEngine::_syncedItems that this folder is done synchronizing.
-    _item->_status = SyncFileItem::Success;
+    if (ok) {
+        _item->_status = SyncFileItem::Success;
+    }
 
     emit itemCompleted(*_item, *this);
     emit finished(_item->_status);
@@ -771,7 +779,13 @@ void CleanupPollsJob::slotPollFinished()
     } else if (job->_item->_status != SyncFileItem::Success) {
         qDebug() << "There was an error with file " << job->_item->_file << job->_item->_errorString;
     } else {
-        _journal->setFileRecord(SyncJournalFileRecord(*job->_item, _localPath + job->_item->_file));
+        if (!_journal->setFileRecord(SyncJournalFileRecord(*job->_item, _localPath + job->_item->_file))) {
+            qWarning() << "database error";
+            job->_item->_status = SyncFileItem::FatalError;
+            job->_item->_errorString = tr("Error writing metadata to the database");
+            emit aborted(job->_item->_errorString);
+            return;
+        }
     }
     // Continue with the next entry, or finish
     start();
diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index dcffe26..eb80420 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -769,7 +769,10 @@ void PropagateDownloadFileQNAM::downloadFinished()
     // Get up to date information for the journal.
     _item->_size = FileSystem::getSize(fn);
 
-    _propagator->_journal->setFileRecord(SyncJournalFileRecord(*_item, fn));
+    if (!_propagator->_journal->setFileRecord(SyncJournalFileRecord(*_item, fn))) {
+        done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
+        return;
+    }
     _propagator->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo());
     _propagator->_journal->commit("download file start2");
     done(isConflict ? SyncFileItem::Conflict : SyncFileItem::Success);
diff --git a/src/libsync/propagateremotemkdir.cpp b/src/libsync/propagateremotemkdir.cpp
index 2b3c0fd..595424a 100644
--- a/src/libsync/propagateremotemkdir.cpp
+++ b/src/libsync/propagateremotemkdir.cpp
@@ -144,7 +144,10 @@ void PropagateRemoteMkdir::success()
 {
     // save the file id already so we can detect rename or remove
     SyncJournalFileRecord record(*_item, _propagator->_localDir + _item->destination());
-    _propagator->_journal->setFileRecord(record);
+    if (!_propagator->_journal->setFileRecord(record)) {
+        done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
+        return;
+    }
 
     done(SyncFileItem::Success);
 }
diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp
index 718b337..0f43683 100644
--- a/src/libsync/propagateremotemove.cpp
+++ b/src/libsync/propagateremotemove.cpp
@@ -165,7 +165,10 @@ void PropagateRemoteMove::finalize()
         record._fileSize = oldRecord._fileSize; // server might have claimed different size, we take the old one from the DB
     }
 
-    _propagator->_journal->setFileRecord(record);
+    if (!_propagator->_journal->setFileRecord(record)) {
+        done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
+        return;
+    }
     _propagator->_journal->commit("Remote Rename");
     done(SyncFileItem::Success);
 }
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index 54708ff..b11c477 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -776,12 +776,16 @@ void PropagateUploadFileQNAM::finalize(const SyncFileItem &copy)
 
     _item->_requestDuration = _duration.elapsed();
 
-    _propagator->_journal->setFileRecord(SyncJournalFileRecord(*_item, _propagator->getFilePath(_item->_file)));
+    _finished = true;
+
+    if (!_propagator->_journal->setFileRecord(SyncJournalFileRecord(*_item, _propagator->getFilePath(_item->_file)))) {
+        done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
+        return;
+    }
     // Remove from the progress database:
     _propagator->_journal->setUploadInfo(_item->_file, SyncJournalDb::UploadInfo());
     _propagator->_journal->commit("upload file start");
 
-    _finished = true;
     done(SyncFileItem::Success);
 }
 
diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp
index a133b67..ac11742 100644
--- a/src/libsync/propagatorjobs.cpp
+++ b/src/libsync/propagatorjobs.cpp
@@ -177,7 +177,10 @@ void PropagateLocalMkdir::start()
     // before the correct etag is stored.
     SyncJournalFileRecord record(*_item, newDirStr);
     record._etag = "_invalid_";
-    _propagator->_journal->setFileRecord(record);
+    if (!_propagator->_journal->setFileRecord(record)) {
+        done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
+        return;
+    }
     _propagator->_journal->commit("localMkdir");
 
     done(SyncFileItem::Success);
@@ -236,7 +239,10 @@ void PropagateLocalRename::start()
     record._contentChecksumType = oldRecord._contentChecksumType;
 
     if (!_item->_isDirectory) { // Directories are saved at the end
-        _propagator->_journal->setFileRecord(record);
+        if (!_propagator->_journal->setFileRecord(record)) {
+            done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
+            return;
+        }
     }
     _propagator->_journal->commit("localRename");
 

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