Skip to content

Commit

Permalink
Fixed file removal
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Apr 6, 2012
1 parent ceaebc4 commit 873da3f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/Look2RemoveMe/App/FileWithRTL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ use warnings;

use base 'Plack::App::File';

use Lamework::Registry;
use Look2RemoveMe::File;

use Plack::Util;
use Plack::MIME;
use File::MimeInfo::Magic ();
use HTTP::Date;
use Plack::MIME;
use Plack::Util;

sub serve_path {
my($self, $env, $file) = @_;

my $content_type = Plack::MIME->mime_type($file) || 'text/plain';
my $content_type = File::MimeInfo::Magic::mimetype($file) || 'text/plain';

if ($content_type =~ m!^text/!) {
$content_type .= "; charset=" . ($self->encoding || "utf-8");
Expand All @@ -26,21 +26,20 @@ sub serve_path {

my $home = Lamework::Registry->get('home');

my $file_to_remove = Look2RemoveMe::File->new_from_path($home->catfile($file));
$file_to_remove->remove;

my @stat = stat $file;

Plack::Util::set_io_path($fh, Cwd::realpath($file));

my $file_to_remove = Look2RemoveMe::File->new_from_path($home->catfile($file));
$file_to_remove->remove;

return [
200,
[
'Content-Type' => $content_type,
'Content-Length' => $stat[7],
'Last-Modified' => HTTP::Date::time2str( $stat[9] )
],
$fh,
$fh
];
}

Expand Down

0 comments on commit 873da3f

Please sign in to comment.