Subject: | One last change to reunify CPAN::Mini with my fork |
When scanning for cleaned files, don't shortcut in the clean_file. Don't even add it to the list by filtering it out during the file scanning phase.
i.e. Where you currently do...
sub clean_unmirrored {
my $self = shift;
find sub {
my $file = canonpath($File::Find::name);
$self->clean_file($file);
}, $self->{local};
}
sub clean_file {
my ($self, $file) = @_;
return unless (-f $file and not $self->{mirrored}{$file});
return if $self->file_allowed($file);
unless (unlink $file) {
warn "$file ... cannot be removed: $!" if $self->{errors};
return;
}
$self->trace("$file ... removed\n");
}
... it might be better to do something like...
sub clean_unmirrored {
my $self = shift;
find sub {
my $file = canonpath($File::Find::name);
return unless (-f $file and not $self->{mirrored}{$file});
return if $self->file_allowed($file);
$self->trace($file);
$self->clean_file($file);
$self->trace(" ... removed\n");
}, $self->{local};
}
sub clean_file {
my ($self, $file) = @_;
unlink $file or warn "Cannot remove $file $!";
}
This keeps the subclasses much cleaner. ->clean_file is only called if it ACTUALY needs to be cleaned, not speculatively.