From 7ecd4513cc9703fa27b1f521a1fc443cc9a3ca33 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 21 Feb 2017 13:24:13 +0000 Subject: Assume photo ID given in database exists on disk. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The list code was checking the photo ID given in the database existed on disk – this shouldn't ever not be the case, and if it was, all that would happen would be a broken image when the full photo code looks for it (this is only for e.g. lists of reports). --- perllib/FixMyStreet/App/Model/PhotoSet.pm | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'perllib/FixMyStreet/App/Model/PhotoSet.pm') diff --git a/perllib/FixMyStreet/App/Model/PhotoSet.pm b/perllib/FixMyStreet/App/Model/PhotoSet.pm index 46e1fb630..04521b5ce 100644 --- a/perllib/FixMyStreet/App/Model/PhotoSet.pm +++ b/perllib/FixMyStreet/App/Model/PhotoSet.pm @@ -191,12 +191,7 @@ has ids => ( # Arrayref of $fileid tuples (always, so post upload/raw data proc $type ||= 'jpeg'; if ($fileid && length($fileid) == 40) { my $file = $self->get_file($fileid, $type); - if ($file->exists) { - $file->basename; - } else { - warn "File $part doesn't exist"; - (); - } + $file->basename; } else { # A bad hash, probably a bot spamming with bad data. (); -- cgit v1.2.3 From 7c62e5da36f84b156dbbce331da7ca3f7961f27f Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 15 Mar 2017 13:57:05 +0000 Subject: Do upload_dir check on start up, not each report. If we're chugging through a list of reports, this save on a lot of pointless statting of the upload directory which we know is there. --- perllib/FixMyStreet/App/Model/PhotoSet.pm | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'perllib/FixMyStreet/App/Model/PhotoSet.pm') diff --git a/perllib/FixMyStreet/App/Model/PhotoSet.pm b/perllib/FixMyStreet/App/Model/PhotoSet.pm index 04521b5ce..8fcc1700e 100644 --- a/perllib/FixMyStreet/App/Model/PhotoSet.pm +++ b/perllib/FixMyStreet/App/Model/PhotoSet.pm @@ -67,14 +67,7 @@ has upload_dir => ( is => 'ro', lazy => 1, default => sub { - my $self = shift; - my $cache_dir = path(FixMyStreet->config('UPLOAD_DIR'))->absolute(FixMyStreet->path_to()); - $cache_dir->mkpath; - unless ( -d $cache_dir && -w $cache_dir ) { - warn "Can't find/write to photo cache directory '$cache_dir'"; - return; - } - $cache_dir; + path(FixMyStreet->config('UPLOAD_DIR'))->absolute(FixMyStreet->path_to()); }, ); -- cgit v1.2.3