[Pkg-owncloud-commits] [owncloud-client] 08/27: Use another way to detect that the server was reconfigured

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Jul 29 16:23:58 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 d697969f36bae0298e146ccbeddea2a6421226da
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Tue Jul 15 11:22:16 2014 +0200

    Use another way to detect that the server was reconfigured
    
    Before, we would only detect it if all the files were removed, and no
    file where added or changed. This may not be enough because there might
    be a welcome.txt file. Now, we check that none of the file stays the same,
    and some files are removed.
    
    Relates issue #1948
---
 src/mirall/folder.cpp     |  5 +----
 src/mirall/syncengine.cpp | 25 ++++++++++++++-----------
 src/mirall/syncengine.h   |  3 ++-
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index fffe544..469543a 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -704,10 +704,7 @@ void Folder::slotTransmissionProgress(const Progress::Info &pi)
 void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction direction, bool *cancel)
 {
 #ifndef TOKEN_AUTH_ONLY
-    QString msg = direction == SyncFileItem::Down ?
-        tr("This sync would remove all the files in the local sync folder '%1'.\n"
-           "If you or your administrator have reset your account on the server, choose "
-           "\"Keep files\". If you want your data to be removed, choose \"Remove all files\".") :
+    QString msg =
         tr("This sync would remove all the files in the sync folder '%1'.\n"
            "This might be because the folder was silently reconfigured, or that all "
            "the file were manually removed.\n"
diff --git a/src/mirall/syncengine.cpp b/src/mirall/syncengine.cpp
index fdb6b5c..c5c45fb 100644
--- a/src/mirall/syncengine.cpp
+++ b/src/mirall/syncengine.cpp
@@ -61,7 +61,8 @@ SyncEngine::SyncEngine(CSYNC *ctx, const QString& localPath, const QString& remo
   , _remoteUrl(remoteURL)
   , _remotePath(remotePath)
   , _journal(journal)
-  , _hasFiles(false)
+  , _hasNoneFiles(false)
+  , _hasRemoveFile(false)
   , _downloadLimit(0)
   , _uploadLimit(0)
 
@@ -330,7 +331,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
             dir = SyncFileItem::None;
         } else {
             // No need to do anything.
-            _hasFiles = true;
+            _hasNoneFiles = true;
 
             emit syncItemDiscovered(item);
             return re;
@@ -343,8 +344,9 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
             _renamedFolders.insert(item._file, item._renameTarget);
         break;
     case CSYNC_INSTRUCTION_REMOVE:
+        _hasRemoveFile = true;
         dir = !remote ? SyncFileItem::Down : SyncFileItem::Up;
-                break;
+        break;
     case CSYNC_INSTRUCTION_CONFLICT:
     case CSYNC_INSTRUCTION_IGNORE:
     case CSYNC_INSTRUCTION_ERROR:
@@ -356,6 +358,11 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
     case CSYNC_INSTRUCTION_STAT_ERROR:
     default:
         dir = remote ? SyncFileItem::Down : SyncFileItem::Up;
+        if (!remote && file->instruction == CSYNC_INSTRUCTION_SYNC) {
+            // An upload of an existing file means that the file was left unchanged on the server
+            // This count as a NONE for detecting if all the file on the server were changed
+            _hasNoneFiles = true;
+        }
         break;
     }
 
@@ -364,11 +371,6 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
     // if the item is on blacklist, the instruction was set to IGNORE
     checkBlacklisting( &item );
 
-    if (file->instruction != CSYNC_INSTRUCTION_IGNORE
-        && file->instruction != CSYNC_INSTRUCTION_REMOVE) {
-      _hasFiles = true;
-    }
-
     if (!item._isDirectory) {
         _progressInfo._totalFileCount++;
         if (Progress::isSizeDependent(file->instruction)) {
@@ -526,7 +528,8 @@ void SyncEngine::slotUpdateFinished(int updateResult)
 
     _progressInfo = Progress::Info();
 
-    _hasFiles = false;
+    _hasNoneFiles = false;
+    _hasRemoveFile = false;
     bool walkOk = true;
     _seenFiles.clear();
 
@@ -556,8 +559,8 @@ void SyncEngine::slotUpdateFinished(int updateResult)
     emit aboutToPropagate(_syncedItems);
     emit transmissionProgress(_progressInfo);
 
-    if (!_hasFiles && !_syncedItems.isEmpty()) {
-        qDebug() << Q_FUNC_INFO << "All the files are going to be removed, asking the user";
+    if (!_hasNoneFiles && _hasRemoveFile) {
+        qDebug() << Q_FUNC_INFO << "All the files are going to be changed, asking the user";
         bool cancel = false;
         emit aboutToRemoveAllFiles(_syncedItems.first()._direction, &cancel);
         if (cancel) {
diff --git a/src/mirall/syncengine.h b/src/mirall/syncengine.h
index 691c1c5..e52ecb8 100644
--- a/src/mirall/syncengine.h
+++ b/src/mirall/syncengine.h
@@ -127,7 +127,8 @@ private:
     QHash<QString, QString> _renamedFolders;
     QString adjustRenamedPath(const QString &original);
 
-    bool _hasFiles; // true if there is at least one file that is not ignored or removed
+    bool _hasNoneFiles; // true if there is at least one file with instruction NONE
+    bool _hasRemoveFile; // true if there is at leasr one file with instruction REMOVE
 
     int _downloadLimit;
     int _uploadLimit;

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