Excludes: drop csyncTraversalMatchFun()

The new discovery can call the traversal match function directly.
This commit is contained in:
Christian Kamm 2018-10-19 10:28:22 +02:00 committed by Kevin Ottens
parent 1d4e4fafcc
commit 4f6f706f40
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
3 changed files with 14 additions and 30 deletions

View 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

View 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.
*
* Careful: The function will only be valid for as long as this
* ExcludedFiles instance stays alive.
* 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).
*/
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
{

View 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;