[Pkg-owncloud-commits] [owncloud-client] 82/159: Sync: Fix sync of deletions during 503. #2894
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri May 1 13:05:26 UTC 2015
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 d986011067a32cea9cf6d3a76581fdfd3c12e4c8
Author: Christian Kamm <kamm at incasoftware.de>
Date: Wed Apr 8 10:50:08 2015 +0200
Sync: Fix sync of deletions during 503. #2894
---
src/libsync/syncengine.cpp | 4 +++-
src/libsync/syncengine.h | 14 ++++++++++++++
src/libsync/syncjournaldb.cpp | 15 ++++++++++++---
src/libsync/syncjournaldb.h | 3 ++-
4 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 22adefd..b9ef9c4 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -384,6 +384,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
case CSYNC_STATUS_STORAGE_UNAVAILABLE:
item._errorString = QLatin1String("Directory temporarily not available on server.");
item._status = SyncFileItem::SoftError;
+ _temporarilyUnavailablePaths.insert(item._file);
break;
default:
Q_ASSERT("Non handled error-status");
@@ -700,6 +701,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
_hasRemoveFile = false;
bool walkOk = true;
_seenFiles.clear();
+ _temporarilyUnavailablePaths.clear();
if( csync_walk_local_tree(_csync_ctx, &treewalkLocal, 0) < 0 ) {
qDebug() << "Error in local treewalk.";
@@ -863,7 +865,7 @@ void SyncEngine::slotFinished()
_anotherSyncNeeded = _anotherSyncNeeded || _propagator->_anotherSyncNeeded;
// emit the treewalk results.
- if( ! _journal->postSyncCleanup( _seenFiles ) ) {
+ if( ! _journal->postSyncCleanup( _seenFiles, _temporarilyUnavailablePaths ) ) {
qDebug() << "Cleaning of synced ";
}
diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h
index 63990ab..6106677 100644
--- a/src/libsync/syncengine.h
+++ b/src/libsync/syncengine.h
@@ -159,7 +159,21 @@ private:
QPointer<DiscoveryMainThread> _discoveryMainThread;
QSharedPointer <OwncloudPropagator> _propagator;
QString _lastDeleted; // if the last item was a path and it has been deleted
+
+ // After a sync, only the syncdb entries whose filenames appear in this
+ // set will be kept. See _temporarilyUnavailablePaths.
QSet<QString> _seenFiles;
+
+ // Some paths might be temporarily unavailable on the server, for
+ // example due to 503 Storage not available. Deleting information
+ // about the files from the database in these cases would lead to
+ // incorrect synchronization.
+ // Therefore all syncdb entries whose filename starts with one of
+ // the paths in this set will be kept.
+ // The specific case that fails otherwise is deleting a local file
+ // while the remote says storage not available.
+ QSet<QString> _temporarilyUnavailablePaths;
+
QThread _thread;
Progress::Info _progressInfo;
diff --git a/src/libsync/syncjournaldb.cpp b/src/libsync/syncjournaldb.cpp
index 27b43fc..20d6edd 100644
--- a/src/libsync/syncjournaldb.cpp
+++ b/src/libsync/syncjournaldb.cpp
@@ -698,7 +698,8 @@ SyncJournalFileRecord SyncJournalDb::getFileRecord( const QString& filename )
return rec;
}
-bool SyncJournalDb::postSyncCleanup(const QSet<QString> &items )
+bool SyncJournalDb::postSyncCleanup(const QSet<QString>& filepathsToKeep,
+ const QSet<QString>& prefixesToKeep)
{
QMutexLocker locker(&_mutex);
@@ -719,8 +720,16 @@ bool SyncJournalDb::postSyncCleanup(const QSet<QString> &items )
while(query.next()) {
const QString file = query.stringValue(1);
- bool contained = items.contains(file);
- if( !contained ) {
+ bool keep = filepathsToKeep.contains(file);
+ if( !keep ) {
+ foreach( const QString & prefix, prefixesToKeep ) {
+ if( file.startsWith(prefix) ) {
+ keep = true;
+ break;
+ }
+ }
+ }
+ if( !keep ) {
superfluousItems.append(query.stringValue(0));
}
}
diff --git a/src/libsync/syncjournaldb.h b/src/libsync/syncjournaldb.h
index 226224b..eb3bc13 100644
--- a/src/libsync/syncjournaldb.h
+++ b/src/libsync/syncjournaldb.h
@@ -97,7 +97,8 @@ public:
*/
void avoidReadFromDbOnNextSync(const QString& fileName);
- bool postSyncCleanup( const QSet<QString>& items );
+ bool postSyncCleanup(const QSet<QString>& filepathsToKeep,
+ const QSet<QString>& prefixesToKeep);
/* Because sqlite transactions is really slow, we encapsulate everything in big transactions
* Commit will actually commit the transaction and create a new one.
--
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