Просмотр исходного кода

Checksums: Skip uploads of .eml files only #4754

This is a workaround. A correct solution would still update file metadata
such as the mtime. See #4755.
Christian Kamm 9 лет назад
Родитель
Сommit
68126dcff6
3 измененных файлов с 9 добавлено и 4 удалено
  1. 1 0
      csync/src/csync_misc.h
  2. 4 1
      csync/src/csync_update.c
  3. 4 3
      csync/tests/ownCloud/t9.pl

+ 1 - 0
csync/src/csync_misc.h

@@ -33,6 +33,7 @@
  * than fmmatch anyway, which does not care for flags.
  **/
 #define FNM_PATHNAME    (1 << 0) /* No wildcard can ever match `/'.  */
+#define FNM_CASEFOLD    (1 << 4) /* Compare without regard to case.  */
 #endif
 
 int csync_fnmatch(__const char *__pattern, __const char *__name, int __flags);

+ 4 - 1
csync/src/csync_update.c

@@ -297,7 +297,10 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
                  // zero size in statedb can happen during migration
                  || (tmp->size != 0 && fs->size != tmp->size))) {
 
-            if (fs->size == tmp->size && tmp->checksumTypeId) {
+            // Checksum comparison at this stage is only enabled for .eml files,
+            // check #4754 #4755
+            bool isEmlFile = csync_fnmatch("*.eml", file, FNM_CASEFOLD) == 0;
+            if (isEmlFile && fs->size == tmp->size && tmp->checksumTypeId) {
                 if (ctx->callbacks.checksum_hook) {
                     st->checksum = ctx->callbacks.checksum_hook(
                                 file, tmp->checksumTypeId,

+ 4 - 3
csync/tests/ownCloud/t9.pl

@@ -59,11 +59,12 @@ my $emlpropafter = remoteFileProp("", "test.eml");
 assert($txtpropafter);
 assert($emlpropafter);
 
-# The both files were not uploaded, nothing differs
-assert($txtpropafter->get_property( "getetag" ) eq
+# The txt file is uploaded normally, etag and mtime differ
+assert($txtpropafter->get_property( "getetag" ) ne
        $txtpropbefore->get_property( "getetag" ));
-assert($txtpropafter->get_property( "getlastmodified" ) eq
+assert($txtpropafter->get_property( "getlastmodified" ) ne
        $txtpropbefore->get_property( "getlastmodified" ));
+# The eml was not uploaded, nothing differs
 assert($emlpropafter->get_property( "getetag" ) eq
        $emlpropbefore->get_property( "getetag" ));
 assert($emlpropafter->get_property( "getlastmodified" ) eq