From 426fa04522d96389251c81d323f594f4b5d575ad Mon Sep 17 00:00:00 2001
From: Daniel Berteaud
Date: Wed, 22 Jul 2015 22:01:24 +0200
Subject: [PATCH] Use a separate dir for tmp
---
.gitignore | 6 ++++--
conf/settings.ini.dist | 4 +++-
{cache => data/cache}/README | 0
data/tmp/README | 1 +
lib/Vroom/Conf.pm | 3 ++-
templates/default/documentation.html.ep | 11 ++++++-----
vroom.pl | 4 ++--
7 files changed, 18 insertions(+), 11 deletions(-)
rename {cache => data/cache}/README (100%)
create mode 100644 data/tmp/README
diff --git a/.gitignore b/.gitignore
index 951e8e5..7d4bceb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
conf/settings.ini
-cache/*
-!cache/README
+data/cache/*
+!data/cache/README
+data/tmp/*
+!data/tmp/README
diff --git a/conf/settings.ini.dist b/conf/settings.ini.dist
index 34cee68..e7560a4 100644
--- a/conf/settings.ini.dist
+++ b/conf/settings.ini.dist
@@ -75,7 +75,9 @@ credentials = 'rest'
[directories]
; Where to store cache data. Defaults to the cache subdirectory
; User running VROOM daemon must have write access
-;cache = 'cache'
+;cache = 'data/cache'
+; Where to store temporary files
+;tmp = 'data/tmp'
[daemon]
; IP the hypnotoad daemon will listen on. You can use * to bind on every IP/Interface
diff --git a/cache/README b/data/cache/README
similarity index 100%
rename from cache/README
rename to data/cache/README
diff --git a/data/tmp/README b/data/tmp/README
new file mode 100644
index 0000000..56dbb1c
--- /dev/null
+++ b/data/tmp/README
@@ -0,0 +1 @@
+This is where temp data are stored
diff --git a/lib/Vroom/Conf.pm b/lib/Vroom/Conf.pm
index d282692..6b7eba7 100644
--- a/lib/Vroom/Conf.pm
+++ b/lib/Vroom/Conf.pm
@@ -39,7 +39,8 @@ sub get_conf(){
$config->{'etherpad.uri'} ||= '';
$config->{'etherpad.api_key'} ||= '';
$config->{'etherpad.base_domain'} ||= '';
- $config->{'directories.cache'} ||= 'cache';
+ $config->{'directories.cache'} ||= 'data/cache';
+ $config->{'directories.cache'} ||= 'data/tmp';
$config->{'daemon.listen_ip'} ||= '127.0.0.1';
$config->{'daemon.listen_port'} ||= '8090';
$config->{'daemon.backend'} ||= 'hypnotoad';
diff --git a/templates/default/documentation.html.ep b/templates/default/documentation.html.ep
index 63ac1a0..32a6577 100644
--- a/templates/default/documentation.html.ep
+++ b/templates/default/documentation.html.ep
@@ -285,14 +285,14 @@ echo "LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so" \\
> /etc/httpd/conf.modules.d/00-proxy_wstunnel.conf
-
- Set permissions on the cache directory
+
+ Set permissions on the cache and tmp directories
- The cache directory must be writeable for the user running the VROOM daemon, which is vroom in the provided systemd unit
+ The cache and tmp directories must be writeable for the user running the VROOM daemon, which is vroom in the provided systemd unit
-chown -R vroom ./cache
-chmod 700 ./cache
+chown -R vroom ./data/{tmp,cache}
+chmod 700 ./data/{cache,tmp}
@@ -447,6 +447,7 @@ cp /opt/vroom/conf/settings.ini.dist /opt/vroom/conf/settings.ini
Controls where to find some specific directories
- cache: This is where VROOM will store its cache (including auto generated and compressed assets like JS and CSS bundles)
+ - tmp: This is where VROOM will store temp data like XLSX files when exporting events
diff --git a/vroom.pl b/vroom.pl
index 02c00cb..de16162 100755
--- a/vroom.pl
+++ b/vroom.pl
@@ -30,7 +30,7 @@ app->log->level('info');
our $config = Vroom::Conf::get_conf();
-# Try to create the cache dir if they doesn't exist
+# Try to create the directories we need
foreach my $dir (qw/assets/){
if (!-d $config->{'directories.cache'} . '/' . $dir){
make_path($config->{'directories.cache'} . '/' . $dir, { mode => 0770 });
@@ -1175,7 +1175,7 @@ helper get_room_conf => sub {
helper export_events_xlsx => sub {
my $self = shift;
my ($from,$to) = @_;
- my $tmp = File::Temp->new( DIR => $config->{'directories.cache'}, SUFFIX => '.xlsx' )->filename;
+ my $tmp = File::Temp->new( DIR => $config->{'directories.tmp'}, SUFFIX => '.xlsx' )->filename;
my $events = $self->get_event_list($from, $to);
if (!$events){
return 0;