csync: ignore files/folder for which stat fails
authorOlivier Goffart <ogoffart@woboq.com>
Fri, 17 Jul 2015 14:48:33 +0000 (16:48 +0200)
committerMarkus Goetz <markus@woboq.com>
Tue, 11 Aug 2015 09:17:20 +0000 (11:17 +0200)
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

csync/src/csync.h
csync/src/csync_exclude.h
csync/src/csync_update.c
src/libsync/syncengine.cpp

index 51f80349e1ebc28f5aaba68f769667bb721ad223..712e3f15b281cc359bd2ea5cca66034d03f69297 100644 (file)
@@ -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;
index 0bdbb6f74fd955b462bcfb2a08c99f9b009f949f..bfb8719396b370bb06f6a824f6e03430a3b61091 100644 (file)
@@ -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;
 
index b5f48df2fe166861db7df4f6907105a704f84ce9..80dca8401a49fc53a3d117945c43b0e8df5b98ef 100644 (file)
@@ -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;
           }
       }
   }
index 5d93eb0c741da857edde6156609c5e8f27ff5fde..dc4a8da1d37dac7ad4583c0bd833154c855dfd6f 100644 (file)
@@ -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;