From: Ian Beckwith Date: Sun, 17 Oct 2010 03:41:12 +0000 (+0100) Subject: fix filter, even though its still disabled. List special dirs last as an optimisation... X-Git-Tag: debian/1.0-1~83 X-Git-Url: http://erislabs.net/gitweb/?p=id3fs.git;a=commitdiff_plain;h=8d3d327aa83769a7c0aa4fb638302757d6411b6c fix filter, even though its still disabled. List special dirs last as an optimisation for filter --- diff --git a/lib/ID3FS/Path.pm b/lib/ID3FS/Path.pm index 60b628f..9020f44 100644 --- a/lib/ID3FS/Path.pm +++ b/lib/ID3FS/Path.pm @@ -82,7 +82,7 @@ sub dirents # print "DIRENTS: FILE: $self->{path}\n"; if($state==$STATE_ALL) { - push(@dents, $PATH_ALLTRACKS, $PATH_NOARTIST, $self->artists()); + @dents=($self->artists(), $PATH_ALLTRACKS, $PATH_NOARTIST); } elsif($state==$STATE_TAG || $state==$STATE_TAGVAL) { @@ -96,11 +96,12 @@ sub dirents } else { - push(@dents, qw(AND OR), $PATH_ALLTRACKS, $PATH_NOARTIST, $self->artists()); + @dents=($self->artists(), qw(AND OR), $PATH_ALLTRACKS, $PATH_NOARTIST); } } elsif($state==$STATE_BOOLEAN) { + @dents=$self->tags(); my $parent=$self->tail(); unless(defined($parent) && ref($parent) eq "ID3FS::PathElement::Boolean" && @@ -108,15 +109,14 @@ sub dirents { push(@dents, "NOT"); } - push(@dents, $self->tags()); } elsif($state==$STATE_ROOT) { - @dents=(qw(ALL NOT), $self->tags()); + @dents=($self->tags(), qw(ALL NOT)); } elsif($state==$STATE_ALBUMS) { - @dents=($PATH_ALLTRACKS, $PATH_NOALBUM, $self->albums()); + @dents=($self->albums(), $PATH_ALLTRACKS, $PATH_NOALBUM); } elsif($state==$STATE_TRACKLIST) { @@ -1016,14 +1016,14 @@ sub filter my $maxdepth=4; for my $dir (@dirs) { -# print "FILTER (",$self->state(), "): $base / $dir\n"; +# print "\nFILTER (",$self->state(), "): $base / $dir\n"; if($self->empty("$base/$dir", $maxdepth)) { # print "empty: $base / $dir\n"; } else { -# print "accepting: $base / $dir\n"; +# print "non-empty, accepting: $base / $dir\n"; push(@outdirs, $dir); } } @@ -1033,7 +1033,7 @@ sub filter sub empty { my($self, $dir, $maxdepth)=@_; - return 1 unless($maxdepth); + return 0 unless($maxdepth); # print "testing($maxdepth): $dir\n"; my $path=ID3FS::Path->new($self->{db}, $dir, $self->{verbose}); # print "PATH INVALID\n" unless($path->isvalid());