my $dbpath=undef;
my $list=0;
my @extensions=qw(mp3 flac ogg);
+my $files_pruned;
Configure(qw(bundling no_ignore_case));
my $optret=GetOptions(
{
$db->last_update(time());
+ my $directories_pruned=$db->prune_directories();
while(my $path=shift)
{
File::Find::find( {wanted => \&wanted, follow => 1, no_chdir => 1}, $path);
}
+ if($files_pruned || $directories_pruned)
+ {
+ print "Removing data from pruned files\n" if $verbose;
+ $db->remove_unused();
+ }
}
sub wanted
if(-d)
{
print("$_\n") if $verbose;
+ prune($_);
}
elsif(-f && scalar(grep({ $ext eq lc($_);} @extensions)))
{
}
}
+
+sub prune
+{
+ my $dir=shift;
+ return unless(opendir(DIR, $dir));
+ print "Pruning $dir\n";
+ my @oldfiles=$db->files_in($dir);
+ my @newfiles=grep { !/^\.\.?$/; } readdir(DIR);
+ closedir(DIR);
+ @oldfiles=sort @oldfiles;
+ @newfiles=sort @newfiles;
+ my %hash;
+ @hash{@newfiles}=();
+ for my $file (@oldfiles)
+ {
+ unless(exists($hash{$file}))
+ {
+ # FIXME: add path, rebasify
+ $files_pruned=1;
+ $db->unindex($file);
+ }
+ }
+}
+
+
+
+
sub list_tags
{
my($db)=@_;