[Pkg-owncloud-commits] [owncloud-client] 03/70: Propagator: Recover from 'precondition failed' error
Sandro Knauß
hefee-guest at moszumanska.debian.org
Tue Jul 1 10:21:17 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 6e10b8c5c46cd2e2a734d1c2e123b535bc09a54e
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue Jun 3 17:22:40 2014 +0200
Propagator: Recover from 'precondition failed' error
When we detect a precondition failed, it is possible that it is
because the etag in the database is wrong. We must therefore not
read from the database on the next sync. In order to avoid that, we
reset the etag of parent directories to invalid values
Fixes #1767
---
src/mirall/propagator_qnam.cpp | 6 ++++++
src/mirall/syncjournaldb.cpp | 22 ++++++++++++++++++++++
src/mirall/syncjournaldb.h | 6 ++++++
3 files changed, 34 insertions(+)
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 78a0cd8..5403a33 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -257,6 +257,12 @@ void PropagateUploadFileQNAM::slotPutFinished()
errorString += QLatin1String(" (") + rx.cap(1) + QLatin1Char(')');
}
+ if (_item._httpErrorCode == 412) {
+ // Precondition Failed: Maybe the bad etag is in the database, we need to clear the
+ // parent folder etag so we won't read from DB next sync.
+ _propagator->_journal->avoidReadFromDbOnNextSync(_item._file);
+ }
+
done(classifyError(err, _item._httpErrorCode), errorString);
return;
}
diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index 90d0753..143637c 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -835,6 +835,28 @@ void SyncJournalDb::avoidRenamesOnNextSync(const QString& path)
}
}
+void SyncJournalDb::avoidReadFromDbOnNextSync(const QString& fileName)
+{
+ //Make sure that on the next sync, filName is not read from the DB but use the PROPFIND to
+ //get the info from the server
+ // We achieve that by clearing the etag of the parents directory recursively
+
+ QMutexLocker locker(&_mutex);
+
+ if( !checkConnect() ) {
+ return;
+ }
+
+ QSqlQuery query(_db);
+ // This query will match entries for whitch the path is a prefix of fileName
+ query.prepare("UPDATE metadata SET md5='_invalid_' WHERE ? LIKE(path||'/%') AND type == 2"); // CSYNC_FTW_TYPE_DIR == 2
+ query.bindValue(0, fileName);
+ if( !query.exec() ) {
+ qDebug() << "SQL error in avoidRenamesOnNextSync: "<< query.lastError().text();
+ } else {
+ qDebug() << query.executedQuery() << fileName;
+ }
+}
void SyncJournalDb::commit(const QString& context, bool startTrans)
{
diff --git a/src/mirall/syncjournaldb.h b/src/mirall/syncjournaldb.h
index 29df0b5..097c297 100644
--- a/src/mirall/syncjournaldb.h
+++ b/src/mirall/syncjournaldb.h
@@ -73,6 +73,12 @@ public:
SyncJournalBlacklistRecord blacklistEntry( const QString& );
void avoidRenamesOnNextSync(const QString &path);
+ /**
+ * Make sure that on the next sync, filName is not read from the DB but use the PROPFIND to
+ * get the info from the server
+ */
+ void avoidReadFromDbOnNextSync(const QString& fileName);
+
bool postSyncCleanup( const QHash<QString, QString>& items );
/* Because sqlite transactions is really slow, we encapsulate everything in big transactions
--
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