[Pkg-owncloud-commits] [owncloud-client] 161/175: Ignores: Force a remote discovery after ignore list change #3172
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:39 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 deb5e68e151033eea184336e4d8dbb7e4cf64599
Author: Christian Kamm <kamm at incasoftware.de>
Date: Fri Jun 19 13:51:55 2015 +0200
Ignores: Force a remote discovery after ignore list change #3172
The problem was that the modified ignore pattern was not applied
to the parts of the remote tree we simply retrieve from the db
because the folder etag didn't change.
Even worse, if one removed an ignore pattern, the un-ignored
files would not be synced correctly.
With this change, a modification to the ignore list always results
in a full remote discovery. This guarantees that we find un-ignored
files.
---
src/gui/accountsettings.cpp | 13 +++++++++++++
src/gui/accountsettings.h | 1 +
src/libsync/syncjournaldb.cpp | 33 +++++++++++++++++++++++++--------
src/libsync/syncjournaldb.h | 10 ++++++++++
4 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index 919bae5..f1fa0d8 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -398,6 +398,18 @@ void AccountSettings::slotSelectiveSync()
}
}
+void AccountSettings::slotForceRemoteDiscoveryOnFolders()
+{
+ FolderMan* folders = FolderMan::instance();
+ foreach (Folder* folder, folders->map()) {
+ if (folder->accountState() != _accountState) {
+ continue;
+ }
+
+ folder->journalDb()->forceRemoteDiscoveryNextSync();
+ }
+}
+
void AccountSettings::slotDoubleClicked( const QModelIndex& indx )
{
if( ! indx.isValid() ) return;
@@ -777,6 +789,7 @@ void AccountSettings::slotIgnoreFilesEditor()
_ignoreEditor = new IgnoreListEditor(this);
_ignoreEditor->setAttribute( Qt::WA_DeleteOnClose, true );
_ignoreEditor->open();
+ connect(_ignoreEditor, SIGNAL(accepted()), SLOT(slotForceRemoteDiscoveryOnFolders()));
} else {
ownCloudGui::raiseDialog(_ignoreEditor);
}
diff --git a/src/gui/accountsettings.h b/src/gui/accountsettings.h
index 94110a9..a6be960 100644
--- a/src/gui/accountsettings.h
+++ b/src/gui/accountsettings.h
@@ -83,6 +83,7 @@ protected slots:
void slotOpenAccountWizard();
void slotHideProgress();
void slotSelectiveSync();
+ void slotForceRemoteDiscoveryOnFolders();
private:
QString shortenFilename( const QString& folder, const QString& file ) const;
diff --git a/src/libsync/syncjournaldb.cpp b/src/libsync/syncjournaldb.cpp
index 9298a12..a3f6a5d 100644
--- a/src/libsync/syncjournaldb.cpp
+++ b/src/libsync/syncjournaldb.cpp
@@ -331,14 +331,7 @@ bool SyncJournalDb::checkConnect()
* In 1.8.1 we had a fix to re-get the data, but this one here is better
*/
if (forceRemoteDiscovery) {
- qDebug() << "Forcing remote re-discovery by deleting folder Etags";
- SqlQuery deleteRemoteFolderEtagsQuery(_db);
- deleteRemoteFolderEtagsQuery.prepare("UPDATE metadata SET md5='_invalid_' WHERE type=2;");
- if( !deleteRemoteFolderEtagsQuery.exec() ) {
- qDebug() << "ERROR: Query failed" << deleteRemoteFolderEtagsQuery.error();
- } else {
- qDebug() << "Cleared" << deleteRemoteFolderEtagsQuery.numRowsAffected() << "folder ETags";
- }
+ forceRemoteDiscoveryNextSyncLocked();
}
_getFileRecordQuery.reset(new SqlQuery(_db));
@@ -1295,6 +1288,30 @@ void SyncJournalDb::avoidReadFromDbOnNextSync(const QString& fileName)
_avoidReadFromDbOnNextSyncFilter.append(fileName);
}
+void SyncJournalDb::forceRemoteDiscoveryNextSync()
+{
+ QMutexLocker locker(&_mutex);
+
+ if( !checkConnect() ) {
+ return;
+ }
+
+ forceRemoteDiscoveryNextSyncLocked();
+}
+
+void SyncJournalDb::forceRemoteDiscoveryNextSyncLocked()
+{
+ qDebug() << "Forcing remote re-discovery by deleting folder Etags";
+ SqlQuery deleteRemoteFolderEtagsQuery(_db);
+ deleteRemoteFolderEtagsQuery.prepare("UPDATE metadata SET md5='_invalid_' WHERE type=2;");
+ if( !deleteRemoteFolderEtagsQuery.exec() ) {
+ qDebug() << "ERROR: Query failed" << deleteRemoteFolderEtagsQuery.error();
+ } else {
+ qDebug() << "Cleared" << deleteRemoteFolderEtagsQuery.numRowsAffected() << "folder ETags";
+ }
+}
+
+
void SyncJournalDb::commit(const QString& context, bool startTrans)
{
QMutexLocker lock(&_mutex);
diff --git a/src/libsync/syncjournaldb.h b/src/libsync/syncjournaldb.h
index 6074631..f6e1f2f 100644
--- a/src/libsync/syncjournaldb.h
+++ b/src/libsync/syncjournaldb.h
@@ -97,6 +97,13 @@ public:
*/
void avoidReadFromDbOnNextSync(const QString& fileName);
+ /**
+ * Ensures full remote discovery happens on the next sync.
+ *
+ * Equivalent to calling avoidReadFromDbOnNextSync() for all files.
+ */
+ void forceRemoteDiscoveryNextSync();
+
bool postSyncCleanup(const QSet<QString>& filepathsToKeep,
const QSet<QString>& prefixesToKeep);
@@ -124,6 +131,9 @@ private:
QStringList tableColumns( const QString& table );
bool checkConnect();
+ // Same as forceRemoteDiscoveryNextSync but without acquiring the lock
+ void forceRemoteDiscoveryNextSyncLocked();
+
SqlDatabase _db;
QString _dbFile;
QMutex _mutex; // Public functions are protected with the mutex.
--
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