From 561e01b9b51b62e2566d80cd63d308f9a4f82822 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Wed, 26 Sep 2018 16:37:40 +0100 Subject: Factor out photo storage backend init checks --- perllib/FixMyStreet/PhotoStorage/FileSystem.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'perllib/FixMyStreet/PhotoStorage/FileSystem.pm') diff --git a/perllib/FixMyStreet/PhotoStorage/FileSystem.pm b/perllib/FixMyStreet/PhotoStorage/FileSystem.pm index 0600f867d..d61a26c7a 100644 --- a/perllib/FixMyStreet/PhotoStorage/FileSystem.pm +++ b/perllib/FixMyStreet/PhotoStorage/FileSystem.pm @@ -16,6 +16,22 @@ has upload_dir => ( }, ); +=head2 init + +Creates UPLOAD_DIR and checks it's writeable. + +=cut + +sub init { + my $self = shift; + my $cache_dir = $self->upload_dir; + $cache_dir->mkpath; + unless ( -d $cache_dir && -w $cache_dir ) { + warn "\x1b[31mCan't find/write to photo cache directory '$cache_dir'\x1b[0m\n"; + return; + } + return 1; +} =head2 get_file -- cgit v1.2.3