From 62464f61cc5d2aed19ef98d3bb31427feef8fa49 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 Apr 2014 13:12:20 +0100 Subject: Also remove cached file when photo removed. --- perllib/FixMyStreet/App/Controller/Admin.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm') diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 9c0018f38..cfe165f43 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -774,7 +774,8 @@ sub report_edit : Path('report_edit') : Args(1) { if ( $c->req->param('remove_photo') ) { $problem->photo(undef); } - if ( $new_state eq 'hidden' ) { + + if ( $c->req->param('remove_photo') || $new_state eq 'hidden' ) { unlink glob FixMyStreet->path_to( 'web', 'photo', $problem->id . '.*' ); } @@ -916,6 +917,10 @@ sub update_edit : Path('update_edit') : Args(1) { $update->photo(undef); } + if ( $c->req->param('remove_photo') || $new_state eq 'hidden' ) { + unlink glob FixMyStreet->path_to( 'web', 'photo', 'c', $update->id . '.*' ); + } + $update->name( $c->req->param('name') || '' ); $update->text( $c->req->param('text') ); $update->anonymous( $c->req->param('anonymous') ); @@ -939,10 +944,6 @@ sub update_edit : Path('update_edit') : Args(1) { } } - if ( $new_state eq 'hidden' ) { - unlink glob FixMyStreet->path_to( 'web', 'photo', 'c', $update->id . '.*' ); - } - $update->update; $c->stash->{status_message} = '

' . _('Updated!') . '

'; -- cgit v1.2.3