$self->{db}=shift;
$self->{source}=shift;
$self->{mountpoint}=Cwd::abs_path(shift);
- $self->{debug}=shift;
+ $self->{verbose}=shift;
$self->{perms} = S_IRUSR() | S_IXUSR() | S_IRGRP() | S_IXGRP() | S_IROTH() | S_IXOTH();
return $self;
Fuse::main(
mountpoint => $self->{mountpoint},
threaded => 0,
- debug => $self->{debug},
+ debug => ($self->{verbose} > 1),
mountopts => "allow_other,ro",
getattr => sub { $self->getattr(@_); },
readlink => sub { $self->readlink(@_); },
{
my($self, $filename)=@_;
# print "**GETATTR: $filename\n";
- my $path=ID3FS::Path->new($self->{db}, $filename);
+ my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose});
my $last_update=$self->{db}->last_update();
return(-ENOENT()) unless($path->isvalid());
my($dev,$ino,$nlink)=(0,0,1);
{
my($self,$filename)=@_;
# print "**READLINK: $filename\n";
- my $path=ID3FS::Path->new($self->{db}, $filename);
+ my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose});
return(-EINVAL()) unless($path->isfile());
return $path->dest($self->{mountpoint});
}
{
my($self, $filename)=@_;
# print "**GETDIR: $filename\n";
- my $path=ID3FS::Path->new($self->{db}, $filename);
+ my $path=ID3FS::Path->new($self->{db}, $filename, $self->{verbose});
return(-ENOENT()) unless($path->isvalid());
return(-ENOTDIR()) unless($path->isdir());
my @dents=();
$self->{elements}=[];
$self->{db}=shift;
$self->{path}=shift;
+ $self->{verbose}=shift;
$self->{path} =~ s/\/\//\//g; # drop doubled slashes
$self->parse();
$sql .= "WHERE " . join(' AND ', @andclauses) . "\n";
}
$sql .= "GROUP BY tags.name;";
-# print "SQL(TAGS): $sql\n";
+ print "SQL(TAGS): $sql\n" if($self->{verbose});
my @tagnames=$self->{db}->cmd_firstcol($sql);
-# print "SUBNAMES: ", join(', ', @tagnames), "\n";
+ print("SUBNAMES: ", join(', ', @tagnames), "\n") if($self->{verbose});
return(@tagnames);
}
"INNER JOIN artists ON files.artists_id=artists.id\n" .
"WHERE artists.name != ''\n" .
"GROUP BY artists.name;");
-# print "SQL(ARTISTS): $sql\n";
+ print "SQL(ARTISTS): $sql\n" if($self->{verbose});
my @tagnames=$self->{db}->cmd_firstcol($sql);
- print "ARTISTS: ", join(', ', @tagnames), "\n";
+ print("ARTISTS: ", join(', ', @tagnames), "\n") if($self->{verbose});
return(@tagnames);
}
"WHERE albums.name != ''\n" .
"GROUP BY albums.name;");
}
-# print "SQL(ALBUMS): \n$sql\n";
+ print "SQL(ALBUMS): \n$sql\n" if($self->{verbose});
my @names=$self->{db}->cmd_firstcol($sql);
- print "ALBUMS: ", join(', ', @names), "\n";
+ print("ALBUMS: ", join(', ', @names), "\n") if($self->{verbose});
return(@names);
}
"INNER JOIN artists ON artists.id=files.artists_id\n" .
"WHERE artists.id=? and albums.name <> ''\n" .
"GROUP BY albums.name\n");
-# print "ARTIST_ALBUMS SQL: $sql\n";
+ print "ARTIST_ALBUMS SQL: $sql\n" if($self->{verbose});
my @albums=$self->{db}->cmd_firstcol($sql, $artist_id);
- print "ALBUMS: ", join(', ', @albums), "\n";
+ print("ALBUMS: ", join(', ', @albums), "\n") if($self->{verbose});
return(@albums);
}
"INNER JOIN albums ON albums.id=files.albums_id\n" .
"WHERE artists.id=? AND albums.name=''\n" .
"GROUP BY files.name\n");
-# print "ARTIST_TRACKS SQL: $sql\n";
+ print "ARTIST_TRACKS SQL: $sql\n" if($self->{verbose});
my @names=$self->{db}->cmd_firstcol($sql, $artist_id);
- print "ARTISTTRACKS: ", join(', ', @names), "\n";
+ print("ARTISTTRACKS: ", join(', ', @names), "\n") if($self->{verbose});
return(@names);
}
"INNER JOIN artists ON artists.id=files.artists_id\n" .
"WHERE artists.id=? AND albums.id=?\n" .
"GROUP BY files.name\n");
-# print "ALBUM_TRACKS SQL($artist_id, $album_id): $sql\n";
+ print "ALBUM_TRACKS SQL($artist_id, $album_id): $sql\n" if($self->{verbose});
my @names=$self->{db}->cmd_firstcol($sql, $artist_id, $album_id);
- print "TRACKS: ", join(', ', @names), "\n";
+ print("TRACKS: ", join(', ', @names), "\n") if($self->{verbose});
return(@names);
}
$sql .= "WHERE artists.name =''\n";
}
$sql .= "GROUP BY files.name;";
-# print "TRACKS SQL($self->{path}): $sql\n";
+ print "TRACKS SQL($self->{path}): $sql\n" if($self->{verbose});
my @names=$self->{db}->cmd_firstcol($sql);
- print "TRACKS: ", join(', ', @names), "\n";
+ print("TRACKS: ", join(', ', @names), "\n") if($self->{verbose});
return(@names);
}
"INNER JOIN paths ON files.paths_id=paths.id\n" .
"WHERE files.id=?\n" .
"GROUP BY paths.name, files.name");
-# print "FILENAME SQL: $sql\n";
+ print "FILENAME SQL: $sql\n" if($self->{verbose});
my ($path, $name)=$self->{db}->cmd_onerow($sql, $id);
my $id3fs_path=join('/', map { $_->{name}; } @{$self->{elements}});
return($self->{db}->relativise($path, $name, $mountpoint, $id3fs_path));
my($self, $dir, $maxdepth)=@_;
return 1 unless($maxdepth);
# print "testing($maxdepth): $dir\n";
- my $path=ID3FS::Path->new($self->{db}, $dir);
+ my $path=ID3FS::Path->new($self->{db}, $dir, $self->{verbose});
# print "PATH INVALID\n" unless($path->isvalid());
return 1 unless($path->isvalid());
my($subdirs,$subfiles)=$path->dirents();