fix filter, even though its still disabled. List special dirs last as an optimisation...
authorIan Beckwith <ianb@erislabs.net>
Sun, 17 Oct 2010 03:41:12 +0000 (04:41 +0100)
committerIan Beckwith <ianb@erislabs.net>
Sun, 17 Oct 2010 03:41:12 +0000 (04:41 +0100)
lib/ID3FS/Path.pm

index 60b628f..9020f44 100644 (file)
@@ -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());