Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csync_update: ignore remote files that cannot be encoded #6177

Merged
merged 1 commit into from
Nov 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/csync/csync.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/csync/csync_exclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 12 additions & 0 deletions src/csync/csync_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -375,6 +385,8 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
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;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down