Skip to content

Commit 1129935

Browse files
committed
use temp directory for xslate cache
We were already deleting the xslate cache directory on startup, because it was having problems with refreshing the templates properly. And in a deployment, we don't have any permanent storage anyway. So we can just use a temp directory for the cache. Since we aren't caching templates anymore, we no longer need the var directory.
1 parent 9aee844 commit 1129935

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ RUN \
4646
cpm install --show-build-log-on-failure --resolver=snapshot
4747
EOT
4848

49-
RUN mkdir var && chown metacpan:users var
50-
5149
ENV PERL5LIB="/app/local/lib/perl5"
5250
ENV PATH="/app/local/bin:${PATH}"
5351

lib/MetaCPAN/Web/View/Xslate.pm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@ package MetaCPAN::Web::View::Xslate;
22
use Moose;
33
extends qw(Catalyst::View::Xslate);
44
use File::Path ();
5+
use File::Temp ();
56
use MetaCPAN::Web::Types qw( AbsPath );
67

78
has '+syntax' => ( default => 'Metakolon' );
89
has '+encode_body' => ( default => 0 );
910
has '+preload' => ( default => 0 );
1011
has '+cache' => ( default => 0 );
1112
has '+cache_dir' => (
12-
isa => AbsPath,
13-
coerce => 1,
13+
isa => AbsPath,
14+
coerce => 1,
15+
default => sub {
16+
File::Temp::tempdir(
17+
TEMPLATE => 'metacpan-web-templates-XXXXXX',
18+
CLEANUP => 1,
19+
TMPDIR => 1,
20+
);
21+
},
1422
);
1523
has '+module' => (
1624
default =>

metacpan_web.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ log4perl_file = log4perl.conf
1313
mark_unauthorized_releases = 0
1414

1515
<View::Xslate>
16-
cache_dir = var/tmp/templates
1716
cache = 1
1817
</View::Xslate>
1918

0 commit comments

Comments
 (0)