Commit ee94f686 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Archive directories of any lists may be created even if archive is...

Archive directories of any lists may be created even if archive is unavailable, or Sympa may crash (#736)
parent 0b10ea17
......@@ -8,7 +8,7 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2018 The Sympa Community. See the AUTHORS.md file at the
# Copyright 2018, 2019 The Sympa Community. See the AUTHORS.md file at the
# top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
......@@ -52,12 +52,13 @@ my $log = Sympa::Log->instance;
sub new {
my $class = shift;
my %options;
my $list;
if (ref $_[0]) { # Compat., not recommended.
$list = shift;
} else {
my %options = @_;
$list = $options{context};
%options = @_;
$list = $options{context};
}
die 'Bug in logic. Ask developer' unless ref $list eq 'Sympa::List';
......@@ -71,17 +72,20 @@ sub new {
_metadatas => undef,
} => $class;
$self->_create_spool();
$self->_create_spool(%options);
return $self;
}
sub _create_spool {
my $self = shift;
my $self = shift;
my %options = @_;
my $umask = umask oct $Conf::Conf{'umask'};
foreach my $directory ($Conf::Conf{'arc_path'}, $self->{base_directory}) {
unless (-d $directory) {
if (-d $directory) {
next;
} elsif ($options{create}) {
$log->syslog('info', 'Creating spool %s', $directory);
unless (
mkdir($directory, 0755)
......@@ -1011,7 +1015,7 @@ L<Sympa::Archive> implements the interface to handle archives.
=over
=item new ( context =E<gt> $list )
=item new ( context =E<gt> $list, [ create =E<gt> 1 ] )
I<Constructor>.
Creates new instance of L<Sympa::Archive>.
......@@ -1024,6 +1028,12 @@ Parameter:
Context of object, a L<Sympa::List> instance.
=item create =E<gt> 1
If necessary, creates directory structure of archive.
Dies if creation fails.
This parameter was introduced on Sympa 6.2.47b.
=back
=item add_archive ( $arc )
......
......@@ -274,7 +274,7 @@ sub _do_rebuildarc {
my $list = shift;
my $arc = shift;
my $archive = Sympa::Archive->new(context => $list);
my $archive = Sympa::Archive->new(context => $list, create => 1);
if ($arc and $arc ne '*') {
$log->syslog('notice', 'Rebuilding %s of %s', $arc, $archive);
......@@ -294,7 +294,7 @@ sub _mail2arc {
my $message = shift;
my $list = $message->{context};
my $archive = Sympa::Archive->new(context => $list);
my $archive = Sympa::Archive->new(context => $list, create => 1);
# chdir $arcpath;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment