Permalink
Browse files

StandAloneBlastPlus.pm: Some temporal files were not deleted

on cleanup() because of open filehandles. Added a check to $self
to close its own filehandle if its file is on the cleanup list.
  • Loading branch information...
1 parent fd580c6 commit f9d399acbeddd74bdb6bc9d2ac3e55d554ae5c1d @fjossandon fjossandon committed Dec 11, 2013
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/Bio/Tools/Run/StandAloneBlastPlus.pm
@@ -1279,7 +1279,18 @@ sub _register_temp_for_cleanup {
sub cleanup {
my $self = shift;
return unless $self->{_cleanup_list};
+
+ my $self_file = '';
+ if (exists $self->{_results}->{_file}) {
+ $self_file = $self->{_results}->{_file};
+ }
for (@{$self->{_cleanup_list}}) {
+ # Close $self_file filehandle if it appears on the cleanup list,
+ # to avoid 'permission denied' errors when unlinking
+ if ($self_file ne '' and $_ =~ m/$self_file$/) {
+ close $self->{_results}->_fh;
+ }
+
m/(\.[a-z0-9_]+)+$/i && do {
unlink $_;
next;

0 comments on commit f9d399a

Please sign in to comment.