diff --git a/lib/LDV/Zerobin.pm b/lib/LDV/Zerobin.pm index f551696..e1d9962 100644 --- a/lib/LDV/Zerobin.pm +++ b/lib/LDV/Zerobin.pm @@ -104,13 +104,14 @@ sub prune my $json = Mojo::JSON->new; foreach my $file (@$files) { next unless $file =~ m/^(\d+)\.json$/oi; - my $paste_time = $1; - my $path = "$storage/$file"; - my $data = $json->decode($self->app->home->slurp_rel_file("$storage/$file")); + my $time = $1; + my $path = $self->app->home->rel_file("$storage/$file"); + my $asset = Mojo::Asset::File->new(path => $path); + my $data = $json->decode($asset->slurp); next if ($data->{expire} > $time); # not yet my $date = strftime("%Y-%m-%d %H:%M", localtime($data->{expire})); $self->app->log->info("Removing expired paste: $file ($date)"); - unlink $self->_paste_path($paste_time); + unlink $path; } 1; } or do { chomp $@;