Changeset 14952


Ignore:
Timestamp:
2008-02-04T13:28:52+13:00 (14 years ago)
Author:
mdewsnip
Message:

Tidied up the code for cleaning up the temporary files, in preparation for adding image caching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/plugins/ImagePlug.pm

    r14951 r14952  
    9696
    9797    my $self = new BasPlug($pluginlist, $inputargs, $hashArgOptLists);
     98    $self->{'tmp_file_paths'} = ();
    9899
    99100    # Check that ImageMagick is installed and available on the path (except for Windows 95/98)
     
    162163    $originalfilename = $filename;
    163164    $filename = &util::get_tmp_filename() . ".$converttotype";
    164     $self->{'tmp_filename'} = $filename;
    165165
    166166    my $result = $self->convert($originalfilename, $filename, "", "");
     
    215215   
    216216    my $thumbnailfile = &util::get_tmp_filename() . ".$thumbnailtype";
    217     $self->{'tmp_filename2'} = $thumbnailfile;
    218217
    219218    # Generate the thumbnail with convert
     
    245244    my $screenviewtype = $self->{'screenviewtype'} || 'jpeg';
    246245    my $screenviewfilename = &util::get_tmp_filename() . ".$screenviewtype";
    247     $self->{'tmp_filename3'} = $screenviewfilename;
    248246
    249247    # make the screenview image
     
    342340    my $result = `$convert_command 2>&1`;
    343341    print $outhandle "$convert_type RESULT = $result\n" if ($verbosity > 2);
     342
     343    push(@{$self->{'tmp_file_paths'}}, $target_file_path);
    344344
    345345    return $result;
     
    438438    # generate_images becuase associated files aren't actually copied
    439439    # until after process has been run.
    440     if (defined $self->{'tmp_filename'} &&
    441     -e $self->{'tmp_filename'}) {
    442       &util::rm($self->{'tmp_filename'})
    443     }
    444 
    445     if (defined $self->{'tmp_filename2'} &&
    446     -e $self->{'tmp_filename2'}) {
    447       &util::rm($self->{'tmp_filename2'})
    448     }
    449     if (defined $self->{'tmp_filename3'} &&
    450     -e $self->{'tmp_filename3'}) {
    451       &util::rm($self->{'tmp_filename3'})
     440    foreach my $tmp_file_path (@{$self->{'tmp_file_paths'}})
     441    {
     442    if (-e $tmp_file_path)
     443    {
     444        &util::rm($tmp_file_path);
     445    }
    452446    }
    453447
Note: See TracChangeset for help on using the changeset viewer.