Excludes: drop csyncTraversalMatchFun()
authorChristian Kamm <mail@ckamm.de>
Fri, 19 Oct 2018 08:28:22 +0000 (10:28 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:13 +0000 (10:58 +0100)
The new discovery can call the traversal match function directly.

src/csync/csync_exclude.cpp
src/csync/csync_exclude.h
src/libsync/discovery.cpp

index de0216553c157fbb59c3a6af0b67c2a38f5ea8c4..2398d10dd02babc8154e1f4837a02da76f7e8ce2 100644 (file)
@@ -562,12 +562,6 @@ CSYNC_EXCLUDE_TYPE ExcludedFiles::fullPatternMatch(const char *path, ItemType fi
     return CSYNC_NOT_EXCLUDED;
 }
 
-auto ExcludedFiles::csyncTraversalMatchFun()
-    -> std::function<CSYNC_EXCLUDE_TYPE(const char *path, ItemType filetype)>
-{
-    return [this](const char *path, ItemType filetype) { return this->traversalPatternMatch(path, filetype); };
-}
-
 /**
  * On linux we used to use fnmatch with FNM_PATHNAME, but the windows function we used
  * didn't have that behavior. wildcardsMatchSlash can be used to control which behavior
index c470da13f48114a44be0c66293bf21082fd71c1d..10eb65e3636c9f359814fbf8e30023e3373d6c86 100644 (file)
@@ -123,14 +123,21 @@ public:
     void setClientVersion(Version version);
 
     /**
-     * Generate a hook for traversal exclude pattern matching
-     * that csync can use.
+     * @brief Check if the given path should be excluded in a traversal situation.
+     *
+     * It does only part of the work that full() does because it's assumed
+     * that all leading directories have been run through traversal()
+     * before. This can be significantly faster.
+     *
+     * That means for 'foo/bar/file' only ('foo/bar/file', 'file') is checked
+     * against the exclude patterns.
      *
-     * Careful: The function will only be valid for as long as this
-     * ExcludedFiles instance stays alive.
+     * @param Path is folder-relative, should not start with a /.
+     *
+     * Note that this only matches patterns. It does not check whether the file
+     * or directory pointed to is hidden (or whether it even exists).
      */
-    auto csyncTraversalMatchFun()
-        -> std::function<CSYNC_EXCLUDE_TYPE(const char *path, ItemType filetype)>;
+    CSYNC_EXCLUDE_TYPE traversalPatternMatch(const char *path, ItemType filetype);
 
 public slots:
     /**
@@ -170,23 +177,6 @@ private:
      */
     CSYNC_EXCLUDE_TYPE fullPatternMatch(const char *path, ItemType filetype) const;
 
-    /**
-     * @brief Check if the given path should be excluded in a traversal situation.
-     *
-     * It does only part of the work that full() does because it's assumed
-     * that all leading directories have been run through traversal()
-     * before. This can be significantly faster.
-     *
-     * That means for 'foo/bar/file' only ('foo/bar/file', 'file') is checked
-     * against the exclude patterns.
-     *
-     * @param Path is folder-relative, should not start with a /.
-     *
-     * Note that this only matches patterns. It does not check whether the file
-     * or directory pointed to is hidden (or whether it even exists).
-     */
-    CSYNC_EXCLUDE_TYPE traversalPatternMatch(const char *path, ItemType filetype);
-
     // Our BasePath need to end with '/'
     class BasePathByteArray : public QByteArray
     {
index 0aba936c102814fbc4f1e7420a72916282d40a41..e581ae68fd576a3fa71aeabe304702ac420e83d5 100644 (file)
@@ -265,7 +265,7 @@ void ProcessDirectoryJob::process()
 bool ProcessDirectoryJob::handleExcluded(const QString &path, bool isDirectory, bool isHidden, bool isSymlink)
 {
     // FIXME! call directly, without char* conversion
-    auto excluded = _discoveryData->_excludes->csyncTraversalMatchFun()(path.toUtf8(), isDirectory ? ItemTypeDirectory : ItemTypeFile);
+    auto excluded = _discoveryData->_excludes->traversalPatternMatch(path.toUtf8(), isDirectory ? ItemTypeDirectory : ItemTypeFile);
 
     // FIXME: move to ExcludedFiles 's regexp ?
     bool isInvalidPattern = false;