diff options
author | Dave Arter <davea@mysociety.org> | 2018-09-26 16:37:40 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-09-28 16:19:47 +0100 |
commit | 561e01b9b51b62e2566d80cd63d308f9a4f82822 (patch) | |
tree | a5f5a9254e3c3f1536a7300b45582ad2ceae51d8 /perllib/FixMyStreet/PhotoStorage/FileSystem.pm | |
parent | 9b2b8675f6dfa22c45d609349f97730a33c975d3 (diff) |
Factor out photo storage backend init checks
Diffstat (limited to 'perllib/FixMyStreet/PhotoStorage/FileSystem.pm')
-rw-r--r-- | perllib/FixMyStreet/PhotoStorage/FileSystem.pm | 16 |
1 files changed, 16 insertions, 0 deletions
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 |