[Pkg-owncloud-commits] [owncloud-client] 14/60: csync_update: ignore remote files that cannot be encoded

Sandro Knauß hefee at debian.org
Sat Dec 16 10:38:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

hefee pushed a commit to branch upstream
in repository owncloud-client.

commit 72809ef5b1aeb578976e4360ed267ac1c4d71ea6
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Tue Nov 21 14:16:01 2017 +0100

    csync_update: ignore remote files that cannot be encoded
    
    This is mainly for linux, whose local is not UTF-8.
    For example, in latin1, it is not possible to encode emoji or chinese character.
    If there are such character in the filename, Qt would just save the file using
    the replacement character ('?'). Then, on the next sync, client would rename
    the files using this replacement character.
    
    Avoid this by ignoring the files which cannot be downloaded because the
    filename cannot be represented with the user's locale
    
    Relates to issue #5676 and #5719
---
 src/csync/csync.h          |  3 ++-
 src/csync/csync_exclude.h  |  3 ++-
 src/csync/csync_update.cpp | 12 ++++++++++++
 src/libsync/syncengine.cpp |  3 +++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/csync/csync.h b/src/csync/csync.h
index 4dfa989..8c59f17 100644
--- a/src/csync/csync.h
+++ b/src/csync/csync.h
@@ -108,7 +108,8 @@ enum csync_status_codes_e {
     CSYNC_STATUS_INDIVIDUAL_STAT_FAILED,
     CSYNC_STATUS_FORBIDDEN,
     CSYNC_STATUS_INDIVIDUAL_TOO_DEEP,
-    CSYNC_STATUS_INDIVIDUAL_IS_CONFLICT_FILE
+    CSYNC_STATUS_INDIVIDUAL_IS_CONFLICT_FILE,
+    CSYNC_STATUS_INDIVIDUAL_CANNOT_ENCODE
 };
 
 typedef enum csync_status_codes_e CSYNC_STATUS;
diff --git a/src/csync/csync_exclude.h b/src/csync/csync_exclude.h
index f55e705..bb66321 100644
--- a/src/csync/csync_exclude.h
+++ b/src/csync/csync_exclude.h
@@ -33,7 +33,8 @@ enum csync_exclude_type_e {
   CSYNC_FILE_EXCLUDE_LONG_FILENAME,
   CSYNC_FILE_EXCLUDE_HIDDEN,
   CSYNC_FILE_EXCLUDE_STAT_FAILED,
-  CSYNC_FILE_EXCLUDE_CONFLICT
+  CSYNC_FILE_EXCLUDE_CONFLICT,
+  CSYNC_FILE_EXCLUDE_CANNOT_ENCODE
 };
 typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE;
 
diff --git a/src/csync/csync_update.cpp b/src/csync/csync_update.cpp
index 495b044..b4787b2 100644
--- a/src/csync/csync_update.cpp
+++ b/src/csync/csync_update.cpp
@@ -46,6 +46,8 @@
 #include "common/utility.h"
 #include "common/asserts.h"
 
+#include <QtCore/QTextCodec>
+
 // Needed for PRIu64 on MinGW in C++ mode.
 #define __STDC_FORMAT_MACROS
 #include <inttypes.h>
@@ -148,6 +150,14 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
       }
   }
 
+  if (ctx->current == REMOTE_REPLICA && QTextCodec::codecForLocale()->mibEnum() != 106) {
+      /* If the locale codec is not UTF-8, we must check that the filename from the server can
+       * be encoded in the local file system. */
+      if (!QTextCodec::codecForLocale()->canEncode(QString::fromUtf8(fs->path))) {
+          excluded = CSYNC_FILE_EXCLUDE_CANNOT_ENCODE;
+      }
+  }
+
   if (fs->type == CSYNC_FTW_TYPE_FILE ) {
     if (fs->modtime == 0) {
       qCDebug(lcUpdate, "file: %s - mtime is zero!", fs->path.constData());
@@ -375,6 +385,8 @@ out:
               fs->error_status = CSYNC_STATUS_INDIVIDUAL_STAT_FAILED;
           } else if (excluded == CSYNC_FILE_EXCLUDE_CONFLICT) {
               fs->error_status = CSYNC_STATUS_INDIVIDUAL_IS_CONFLICT_FILE;
+          } else if (excluded == CSYNC_FILE_EXCLUDE_CANNOT_ENCODE) {
+              fs->error_status = CSYNC_STATUS_INDIVIDUAL_CANNOT_ENCODE;
           }
       }
   }
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 1125876..f8a7018 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -476,6 +476,9 @@ int SyncEngine::treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other,
     case CSYNC_STATUS_INDIVIDUAL_TOO_DEEP:
         item->_errorString = tr("Folder hierarchy is too deep");
         break;
+    case CSYNC_STATUS_INDIVIDUAL_CANNOT_ENCODE:
+        item->_errorString = tr("The filename cannot be encoded on your file system.");
+        break;
     case CSYNC_STATUS_INDIVIDUAL_IS_CONFLICT_FILE:
         item->_status = SyncFileItem::Conflict;
         if (Utility::shouldUploadConflictFiles()) {

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