Compare commits

...

3 commits

Author SHA1 Message Date
Andrea Mazzoleni
b40f0a596d Update CHECKSUMS
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-win (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
2026-04-01 00:49:54 +02:00
Andrea Mazzoleni
06b2dab81c Update HISTORY 2026-04-01 00:43:11 +02:00
Andrea Mazzoleni
ea5f8d0f5f Fix filter matching of directory specifications 2026-04-01 00:32:07 +02:00
5 changed files with 53 additions and 16 deletions

View file

@ -161,4 +161,11 @@ e2f44b06d2065226e6d2b184f9bf046bb0ce5144a585eadb14f83e19c349cc86 snapraid-13.0-
59b8b09e20a5937e0cd2798b1256eefa1cd27bd3f1c24b5e4dee32e6b25c1553 snapraid-14.0-windows-x64.zip
b6a144161e7240c754947d5ea4f637f59006cbdaed68c2f285f440c257e7590e snapraid-14.0-windows-x86.zip
b67183342cc4160891dfdf10452f1c79e71bb7887c54fcfb81cd2ded68b3bd37 snapraid-14.0-x86_64-1_am.txz
b33e19558ad0f29f1c8d3907a772377f1125f19b44003db8b8df05cec46cd7c6 snapraid-14.1.tar.gz
d0cb38415284e88cb6f7253ef8389aa207c3689e0276196808773bd37aeb6552 snapraid-14.1-1-x86_64.pkg.tar.zst
a754c6acd9c0efd8de89b698ff7bf422299f30de222c99db42a597b21f272429 snapraid-14.1-1.x86_64.rpm
0bb740d84b446aafc87fb8f188cb87d1429a7c3243b9339633f8a237dfc2b987 snapraid-14.1-windows-x64.zip
f796fc232bc578e9b3007e50dc543dcb9a8a9ab721eaf0b805a0e25c53e573e5 snapraid-14.1-windows-x86.zip
a15c366093e7184b72e51797fcf6429858374810c35694a0c7fb9cb044c5f7ff snapraid-14.1-x86_64-1_am.txz
128b5b0f80a6a0911e77ed3b5d9d81529f5ea1d8fffbb5112e3af3467d80464a snapraid_14.0-1_amd64.deb
b9c41ae2e8edbc413abd3172b7ed2da2cba7fa0e631d0f47fc1dafccf7c6e92c snapraid_14.1-1_amd64.deb

View file

@ -1,6 +1,12 @@
SnapRAID HISTORY
================
14.1 2026/03
============
* Fix include/exclude specification of directories.
* Fix a build issue in Alpine distribution.
* Fix abort condition if the Windows volume name cannot be converted to UTF-8.
14.0 2026/03
============
* More log tags for all commands in preparation for the upcoming SnapRAID

View file

@ -186,27 +186,35 @@ static int filter_apply(struct snapraid_filter* filter, struct snapraid_filter**
path += strlen(filter->root);
}
/* match dirs with dirs and files with files */
if (filter->is_dir && !is_dir)
return 0;
/* if the filter is for files, it doesn't applies to directories */
if (!filter->is_dir && is_dir)
return 0;
/*
* If the filter is for directories, it should be applied to all files inside
* that directory.
*
* This is done allowing a partial matching as far it ends at a directory separator
*/
int match_sub = 0;
if (filter->is_dir && !is_dir)
match_sub = 1;
int ret = 0;
if (filter->is_abs) {
/* skip initial slash, as always missing in the path */
if (wnmatch(filter->pattern + 1, path) == 0)
if (wnmatch_sub(filter->pattern + 1, path, match_sub) == 0)
ret = filter->direction;
} else {
/* the path is relative, first try to match from the root */
if (wnmatch(filter->pattern, path) == 0) {
if (wnmatch_sub(filter->pattern, path, match_sub) == 0) {
ret = filter->direction;
} else {
/* then try to match after all the / presents */
char* slash = strchr(path, '/');
while (slash) {
if (wnmatch(filter->pattern, slash + 1) == 0) {
if (wnmatch_sub(filter->pattern, slash + 1, match_sub) == 0) {
ret = filter->direction;
break;
}

View file

@ -2541,7 +2541,7 @@ static const char* match_class(const char* p, char t)
return p;
}
int wnmatch(const char* p, const char* t)
int wnmatch_sub(const char* p, const char* t, int match_sub)
{
char p1 = 0; /* previous char */
while (*p) {
@ -2582,20 +2582,20 @@ int wnmatch(const char* p, const char* t)
*/
if (*p == '/' && (p1 == 0 || p1 == '/')) {
/* try reducing to nothing */
if (wnmatch(p + 1, t) == 0)
if (wnmatch_sub(p + 1, t, match_sub) == 0)
return 0;
/* otherwise / should match in the text */
}
/* try matching with 0 or more characters */
while (*t) {
if (wnmatch(p, t) == 0)
if (wnmatch_sub(p, t, match_sub) == 0)
return 0;
++t;
}
/* try matching at the end */
return wnmatch(p, t);
return wnmatch_sub(p, t, match_sub);
}
} else {
/* skip the * */
@ -2611,13 +2611,13 @@ int wnmatch(const char* p, const char* t)
/* try matching with 0 or more characters */
while (*t && *t != '/') {
if (wnmatch(p, t) == 0)
if (wnmatch_sub(p, t, match_sub) == 0)
return 0;
++t;
}
/* try matching at the end */
return wnmatch(p, t);
return wnmatch_sub(p, t, match_sub);
case '[' :
/* character class */
if (*t == 0 || *t == '/')
@ -2640,7 +2640,13 @@ int wnmatch(const char* p, const char* t)
p1 = p0;
}
/* match successful if we've consumed all text */
return *t != 0;
/* if we match sub directory */
if (match_sub) {
/* match successfully only if we are at a directory border */
return *t != '/';
} else {
/* match successfully if we've consumed all text */
return *t != 0;
}
}

View file

@ -523,14 +523,24 @@ void thread_yield(void);
/*
* Wild match function.
*
* If match_sub is !=0, it matches sub directory. Specifically it matches if the
* string "t" is not fully consumed and the next character to consume is a /.
*
* - ? matches any single character except /
* - * matches any sequence of characters except /
* - ** (nearby a /) matches everything including /
* - ** (not near a /) like *
* - ##/ reduces to nothing in addition to the normal matching of ** (using # instead of * to mess the C comment)
* - ##/ reduces to nothing in addition to the normal matching of ** (using # instead of * to not mess the C comment)
* - [...] matches character classes with support for ranges and negation lile [!...] or [^...], except /
*
* \return 0 if it matches
*/
int wnmatch(const char* p, const char* t);
int wnmatch_sub(const char* p, const char* t, int match_sub);
static inline int wnmatch(const char* p, const char* t)
{
return wnmatch_sub(p, t, 0);
}
#endif