Skip to content

Commit

Permalink
use temp directory for xslate cache
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
haarg committed Oct 28, 2024
1 parent 9aee844 commit 1129935
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ RUN \
cpm install --show-build-log-on-failure --resolver=snapshot
EOT

RUN mkdir var && chown metacpan:users var

ENV PERL5LIB="/app/local/lib/perl5"
ENV PATH="/app/local/bin:${PATH}"

Expand Down
12 changes: 10 additions & 2 deletions lib/MetaCPAN/Web/View/Xslate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ package MetaCPAN::Web::View::Xslate;
use Moose;
extends qw(Catalyst::View::Xslate);
use File::Path ();
use File::Temp ();
use MetaCPAN::Web::Types qw( AbsPath );

has '+syntax' => ( default => 'Metakolon' );
has '+encode_body' => ( default => 0 );
has '+preload' => ( default => 0 );
has '+cache' => ( default => 0 );
has '+cache_dir' => (
isa => AbsPath,
coerce => 1,
isa => AbsPath,
coerce => 1,
default => sub {
File::Temp::tempdir(
TEMPLATE => 'metacpan-web-templates-XXXXXX',
CLEANUP => 1,
TMPDIR => 1,
);
},
);
has '+module' => (
default =>
Expand Down
1 change: 0 additions & 1 deletion metacpan_web.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ log4perl_file = log4perl.conf
mark_unauthorized_releases = 0

<View::Xslate>
cache_dir = var/tmp/templates
cache = 1
</View::Xslate>

Expand Down

0 comments on commit 1129935

Please sign in to comment.