From: Olivier Goffart Date: Fri, 17 Jul 2015 14:48:33 +0000 (+0200) Subject: csync: ignore files/folder for which stat fails X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1408^2~263 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9dcce01e543dd26bbe98b3db6bdc881e7cc016dd;p=nextcloud-desktop.git csync: ignore files/folder for which stat fails instead of pretending it suicceed and not recursing in it. This fixes a bug in which a folder with a too long name would be properly created, then removed on the server in the next sync. (cherry picked from commit 4bbf7669091cde7ec726b1708d8c54427b68f016) Conflicts: csync/src/csync.h csync/src/csync_exclude.h csync/src/csync_update.c --- diff --git a/csync/src/csync.h b/csync/src/csync.h index 51f80349e..712e3f15b 100644 --- a/csync/src/csync.h +++ b/csync/src/csync.h @@ -101,7 +101,8 @@ enum csync_status_codes_e { CSYNC_STATUS_INDIVIDUAL_EXCLUDE_LONG_FILENAME, CYSNC_STATUS_FILE_LOCKED_OR_OPEN, CSYNC_STATUS_INDIVIDUAL_EXCLUDE_HIDDEN, - CSYNC_STATUS_INVALID_CHARACTERS + CSYNC_STATUS_INVALID_CHARACTERS, + CSYNC_STATUS_INDIVIDUAL_STAT_FAILED }; typedef enum csync_status_codes_e CSYNC_STATUS; diff --git a/csync/src/csync_exclude.h b/csync/src/csync_exclude.h index 0bdbb6f74..bfb871939 100644 --- a/csync/src/csync_exclude.h +++ b/csync/src/csync_exclude.h @@ -28,7 +28,8 @@ enum csync_exclude_type_e { CSYNC_FILE_EXCLUDE_LIST, CSYNC_FILE_EXCLUDE_INVALID_CHAR, CSYNC_FILE_EXCLUDE_LONG_FILENAME, - CSYNC_FILE_EXCLUDE_HIDDEN + CSYNC_FILE_EXCLUDE_HIDDEN, + CSYNC_FILE_EXCLUDE_STAT_FAILED }; typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE; diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c index b5f48df2f..80dca8401 100644 --- a/csync/src/csync_update.c +++ b/csync/src/csync_update.c @@ -163,8 +163,12 @@ static int _csync_detect_update(CSYNC *ctx, const char *file, len = strlen(path); - /* Check if file is excluded */ - excluded = csync_excluded(ctx, path,type); + if (type == CSYNC_FTW_TYPE_SKIP) { + excluded =CSYNC_FILE_EXCLUDE_STAT_FAILED; + } else { + /* Check if file is excluded */ + excluded = csync_excluded(ctx, path,type); + } if( excluded == CSYNC_NOT_EXCLUDED ) { /* Even if it is not excluded by a pattern, maybe it is to be ignored @@ -235,12 +239,6 @@ static int _csync_detect_update(CSYNC *ctx, const char *file, } } - /* Ignore non statable files and other strange cases. */ - if (type == CSYNC_FTW_TYPE_SKIP) { - st->instruction = CSYNC_INSTRUCTION_NONE; - goto out; - } - if (excluded > CSYNC_NOT_EXCLUDED || type == CSYNC_FTW_TYPE_SLINK) { st->instruction = CSYNC_INSTRUCTION_IGNORE; if (ctx->current_fs) { @@ -433,6 +431,8 @@ out: st->error_status = CSYNC_STATUS_INDIVIDUAL_EXCLUDE_LONG_FILENAME; /* File name is too long. */ } else if (excluded == CSYNC_FILE_EXCLUDE_HIDDEN ) { st->error_status = CSYNC_STATUS_INDIVIDUAL_EXCLUDE_HIDDEN; + } else if (excluded == CSYNC_FILE_EXCLUDE_STAT_FAILED) { + st->error_status = CSYNC_STATUS_INDIVIDUAL_STAT_FAILED; } } } diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 5d93eb0c7..dc4a8da1d 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -403,6 +403,9 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote ) case CYSNC_STATUS_FILE_LOCKED_OR_OPEN: item->_errorString = QLatin1String("File locked"); // don't translate, internal use! break; + case CSYNC_STATUS_INDIVIDUAL_STAT_FAILED: + item._errorString = tr("Stat failed."); + break; case CSYNC_STATUS_SERVICE_UNAVAILABLE: item->_errorString = QLatin1String("Server temporarily unavailable."); break;