Commit 75244cb2 authored by sikeda's avatar sikeda
Browse files

[dev] Refactoring: Sympa::Archive is now a class. Messages fetched will be...

[dev] Refactoring: Sympa::Archive is now a class.  Messages fetched will be locked to prevent access by multiple processes.
Several methods was introduced: See POD of Sympa::Archive.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12077 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 6da23351
......@@ -24,7 +24,7 @@ Content-Type: message/rfc822
Content-Disposition: inline
X-Sympa-Attach: yes
[% m.full_msg %]
[%# m.full_msg #%]
[% END %]
--[% boundary2 %]
......
......@@ -95,6 +95,7 @@ man3ext = 3Sympa
MAN3PM = \
Sympa.pm \
Sympa/Alarm.pm \
Sympa/Archive.pm \
Sympa/Bulk.pm \
Sympa/ConfDef.pm \
Sympa/Constants.pm \
......
This diff is collapsed.
......@@ -502,14 +502,6 @@ sub getfile {
$which, $file, $sender);
return 'not_allowed';
}
# unless ($list->archive_exist($file)) {
# Sympa::Report::reject_report_cmd('user', 'no_required_file', {},
# $cmd_line);
# $log->syslog('info',
# 'GET %s %s from %s refused, archive not found for list %s',
# $which, $file, $sender, $which);
# return 'no_archive';
# }
unless ($list->archive_send($sender, $file)) {
Sympa::Report::reject_report_cmd(
......@@ -737,11 +729,23 @@ sub index {
return 'no_archive';
}
my @l = $list->archive_ls();
my @arcs;
if ($list->is_archived) {
my $archive = Sympa::Archive->new($list);
foreach my $arc ($archive->get_archives) {
my $info = $archive->select_archive($arc, info => 1);
next unless $info;
push @arcs, sprintf "%-40s %7d %s\n", $arc, $info->{size},
$language->gettext_strftime('%a, %d %b %Y %H:%M:%S',
localtime $info->{mtime});
}
}
unless (
Sympa::send_file(
$list, 'index_archive', $sender,
{'archives' => \@l, 'auto_submitted' => 'auto-replied'}
{'archives' => \@arcs, 'auto_submitted' => 'auto-replied'}
)
) {
$log->syslog('notice',
......
......@@ -249,6 +249,7 @@ Returns true if the list is moderated.
=item archive_exist ( FILE )
DEPRECATED.
Returns true if the indicated file exists.
=item archive_send ( WHO, FILE )
......@@ -257,6 +258,7 @@ Send the indicated archive file to the user, if it exists.
=item archive_ls ()
DEPRECATED.
Returns the list of available files, if any.
=item archive_msg ( MSG )
......@@ -2814,27 +2816,46 @@ sub send_confirm_to_sender {
#
######################################################
sub archive_send {
my ($self, $who, $file) = @_;
$log->syslog('debug', '(%s, %s)', $who, $file);
my ($self, $who, $arc) = @_;
$log->syslog('debug', '(%s, %s)', $who, $arc);
return unless ($self->is_archived());
return unless $self->is_archived();
my $archive = Sympa::Archive->new($self);
my @msg_list;
if ($archive->select_archive($arc)) {
while (1) {
my ($message, $handle) = $archive->next;
last unless $handle; # No more messages.
next unless $message; # Malformed message.
# Decrypt message if possible
$message->smime_decrypt;
my $msg_list = Sympa::Archive::scan_dir_archive($self, $file);
$log->syslog('debug', 'MAIL object: %s', $message);
my $subject = 'File ' . $self->{'name'} . ' ' . $file;
push @msg_list,
{
id => $message->{serial},
subject => $message->{decoded_subject},
from => $message->get_decoded_header('From'),
date => $message->get_decoded_header('Date'),
full_msg => $message->as_string
};
}
}
my $subject = 'File ' . $self->{'name'} . ' ' . $arc;
my $param = {
'to' => $who,
'subject' => $subject,
'msg_list' => $msg_list
'msg_list' => [@msg_list]
};
$param->{'boundary1'} = tools::get_message_id($self->{'domain'});
$param->{'boundary2'} = tools::get_message_id($self->{'domain'});
$param->{'from'} = Conf::get_robot_conf($self->{'domain'}, 'sympa');
# open TMP2, ">/tmp/digdump";
# Sympa::Tools::Data::dump_var($param, 0, \*TMP2);
# close TMP2;
$param->{'auto_submitted'} = 'auto-replied';
unless (Sympa::send_file($self, 'get_archive', $who, $param)) {
$log->syslog('notice', 'Unable to send template "archive_send" to %s',
......@@ -5771,41 +5792,24 @@ sub is_digest {
}
## Does the file exist?
sub archive_exist {
my ($self, $file) = @_;
$log->syslog('debug', '(%s)', $file);
return undef unless ($self->is_archived());
my $dir =
Conf::get_robot_conf($self->{'domain'}, 'arc_path') . '/'
. $self->get_list_id();
Sympa::Archive::exist($dir, $file);
}
# DEPRECATED. No longer used.
#sub archive_exist;
## List the archived files
sub archive_ls {
my $self = shift;
$log->syslog('debug2', '');
my $dir =
Conf::get_robot_conf($self->{'domain'}, 'arc_path') . '/'
. $self->get_list_id();
Sympa::Archive::list($dir) if ($self->is_archived());
}
# DEPRECATED. Use Sympa::Archive::get_archives().
#sub archive_ls;
sub archive_msg {
$log->syslog('debug2', '(%s, %s)', @_);
my ($self, $message) = @_;
if ($self->is_archiving_enabled) {
my $msg_string = $message->to_string(
Sympa::Archive->new($self)->store_last(
$message,
original => Sympa::Tools::Data::smart_eq(
$self->{admin}{archive_crypted_msg}, 'original'
)
);
Sympa::Archive::store_last($self, $msg_string);
# Ignoring message with a no-archive flag
if (!Sympa::Tools::Data::smart_eq(
......
......@@ -77,6 +77,8 @@ sub _create_spool {
sub next {
my $self = shift;
return unless $self->{directory};
unless ($self->{_metadatas}) {
my $dh;
unless (opendir $dh, $self->{directory}) {
......
This diff is collapsed.
Supports Markdown
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