Compare commits

...

2 Commits

2 changed files with 15 additions and 8 deletions

View File

@ -193,7 +193,7 @@ extern(System)
threads from the runtime because after fuse_main finishes the pthreads threads from the runtime because after fuse_main finishes the pthreads
are joined. We circumvent that problem by just exiting while our are joined. We circumvent that problem by just exiting while our
threads still run. */ threads still run. */
import std.c.process; import core.stdc.stdlib : exit;
exit(0); exit(0);
} }
} /* extern(C) */ } /* extern(C) */

View File

@ -115,6 +115,15 @@ class FileSystem : Operations
return _fileLinkCache[name]; return _fileLinkCache[name];
} }
Tuple!(bool, "exclude", string, "name")[] pathToTagTuples(const(char)[] path)
{
//map the path to a range of tuples with an exclude (bool) and a name (string) field for each tag in the path
return pathSplitter(path)
.array[1..$]
.map!(tag => tuple!("exclude", "name")(tag[0] == exclusionChar, cast(immutable)tag.stripLeft(exclusionChar)))
.array;
}
string[] getTags(const(char)[] path) string[] getTags(const(char)[] path)
{ {
if(path == "/") if(path == "/")
@ -123,12 +132,13 @@ class FileSystem : Operations
} }
else else
{ {
auto tags = pathSplitter(path).array[1..$]; auto tags = pathToTagTuples(path);
auto filePairs = _tagCache.byKeyValue().filter!(a => tags.all!(b => a.value.canFind(b))); //filter pairs with tags that (should not be excluded && can be found) || (should be excluded && can't be found)
auto filePairs = _tagCache.byKeyValue().filter!(a => tags.all!(b => !b.exclude == a.value.canFind(b.name)));
return filePairs.map!(a => a.value) return filePairs.map!(a => a.value)
.joiner .joiner
.filter!(a => !tags.canFind(a)) .filter!(a => !tags.map!(tag => tag.name).canFind(a)) //don't match tags that are already in the path
.filter!(a => !_noCommon || !filePairs.all!(f => f.value.canFind(a))) .filter!(a => !_noCommon || !filePairs.all!(f => f.value.canFind(a)))
.array .array
.sort() .sort()
@ -145,10 +155,7 @@ class FileSystem : Operations
} }
else else
{ {
//map the path to a range of tuples with an exclude (bool) and a name (string) field for each tag in the path auto tags = pathToTagTuples(path);
auto tags = pathSplitter(path)
.array[1..$]
.map!(tag => tuple!("exclude", "name")(tag[0] == exclusionChar, tag.stripLeft(exclusionChar)));
//filter files with tags that (should not be excluded && can be found) || (should be excluded && can't be found) //filter files with tags that (should not be excluded && can be found) || (should be excluded && can't be found)
return _tagCache.byKeyValue() return _tagCache.byKeyValue()