This commit is contained in:
Luc Didry 2015-10-11 13:32:21 +02:00 committed by Luc Didry
parent 4feff52664
commit f94ae4348b
4 changed files with 14 additions and 5 deletions

View File

@ -16,7 +16,7 @@ test:
clean: clean:
rm -rf lufi.db files/ rm -rf lufi.db files/
dev: clean dev: clean
$(CARTON) morbo $(LUFI) --listen http://0.0.0.0:3000 --watch lib/ --watch script/ --watch themes/ $(CARTON) morbo $(LUFI) --listen http://0.0.0.0:3000 --watch lib/ --watch script/ --watch themes/ --watch lufi.conf
devlog: devlog:
multitail log/development.log multitail log/development.log

View File

@ -23,6 +23,7 @@ sub startup {
}, },
mail_sender => 'no-reply@lufi.io', mail_sender => 'no-reply@lufi.io',
theme => 'default', theme => 'default',
upload_dir => 'files',
} }
}); });
@ -170,7 +171,8 @@ sub startup {
$self->provisioning(); $self->provisioning();
# Create directory if needed # Create directory if needed
mkdir('files', 0700) unless (-d 'files'); mkdir($self->config('upload_dir'), 0700) unless (-d $self->config('upload_dir'));
die ('The upload directory ('.$self->config('upload_dir').') is not writable') unless (-w $self->config('upload_dir'));
# Default layout # Default layout
$self->defaults(layout => 'default'); $self->defaults(layout => 'default');

View File

@ -44,7 +44,7 @@ sub upload {
} }
} }
# Check that we have enough space (multiplying by 2 since it's encrypted, it takes more place that the original file) # Check that we have enough space (multiplying by 2 since it's encrypted, it takes more place that the original file)
elsif ($json->{part} == 0 && ($json->{size} * 2) >= dfportable('files')->{bavail}) { elsif ($json->{part} == 0 && ($json->{size} * 2) >= dfportable($c->config('upload_dir'))->{bavail}) {
$stop = 1; $stop = 1;
$c->send(sprintf('{"success": false, "msg":"'.$c->l('No enough space available on the server for this file (size: %1).', format_bytes($json->{size})).'", "sent_delay": %d, "i": %d}', $json->{delay}, $json->{i})); $c->send(sprintf('{"success": false, "msg":"'.$c->l('No enough space available on the server for this file (size: %1).', format_bytes($json->{size})).'", "sent_delay": %d, "i": %d}', $json->{delay}, $json->{i}));
} }
@ -94,7 +94,7 @@ sub upload {
# In this case, we don't need to rewrite the file # In this case, we don't need to rewrite the file
unless ($f->slices->grep(sub { $_->j == $json->{part} })->size) { unless ($f->slices->grep(sub { $_->j == $json->{part} })->size) {
# Create directory # Create directory
my $dir = catdir('files', $f->short); my $dir = catdir($c->config('upload_dir'), $f->short);
mkdir($dir, 0700) unless (-d $dir); mkdir($dir, 0700) unless (-d $dir);
# Create slice file # Create slice file

View File

@ -104,10 +104,17 @@
# define a path to the SQLite database # define a path to the SQLite database
# you can define it relative to lufi directory or set an absolute path # you can define it relative to lufi directory or set an absolute path
# remember that it has to be in a directory writable by Lutim user # remember that it has to be in a directory writable by Lufi user
# optional, default is lufi.db # optional, default is lufi.db
#db_path => 'lufi.db', #db_path => 'lufi.db',
# define a path to the upload directory, where the uploaded files will be stored
# you can define it relative to lufi directory or set an absolute path
# remember that it has to be in a directory writable by Lufi user
# DO NOT CHANGE THIS IF FILES HAVE BEEN ALREADY UPLOADED: THEY WILL NOT BE DOWNLOADABLE ANYMORE
# optional, default is 'files'
#upload_dir => 'files',
######################### #########################
# Lufi cron jobs settings # Lufi cron jobs settings
######################### #########################