Update Qpsmtpd::DB to work with multiple stores
This commit is contained in:
parent
b335e26078
commit
ecb6d2c1d5
@ -5,12 +5,26 @@ use Qpsmtpd::DB::File::DBM;
|
|||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %arg ) = @_;
|
my ( $class, %arg ) = @_;
|
||||||
# The only supported class just now
|
# Qpsmtpd::DB::File::DBM is the only supported class just now
|
||||||
return bless { %arg }, 'Qpsmtpd::DB::File::DBM';
|
my @child_classes = qw(
|
||||||
|
Qpsmtpd::DB::File::DBM
|
||||||
|
);
|
||||||
|
my $manual_class = delete $arg{class};
|
||||||
|
return $manual_class->new(%arg) if $manual_class;
|
||||||
|
my ( $child, @errors );
|
||||||
|
for my $child_class ( @child_classes ) {
|
||||||
|
eval {
|
||||||
|
$child = $child_class->new(%arg);
|
||||||
|
};
|
||||||
|
last if ! $@;
|
||||||
|
push @errors, "Couldn't load $child_class: $@";
|
||||||
|
}
|
||||||
|
return $child if $child;
|
||||||
|
die join( "\n", "Couldn't load any storage modules", @errors );
|
||||||
}
|
}
|
||||||
|
|
||||||
# noop default method for plugins that don't require locking
|
# noop default method for plugins that don't require locking
|
||||||
sub get_lock { 1 }
|
sub lock { 1 }
|
||||||
|
|
||||||
sub name {
|
sub name {
|
||||||
my ( $self, $name ) = @_;
|
my ( $self, $name ) = @_;
|
||||||
|
@ -3,6 +3,11 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use parent 'Qpsmtpd::DB';
|
use parent 'Qpsmtpd::DB';
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ( $class, %arg ) = @_;
|
||||||
|
return bless { %arg }, $class;
|
||||||
|
}
|
||||||
|
|
||||||
sub dir {
|
sub dir {
|
||||||
my ( $self, @candidate_dirs ) = @_;
|
my ( $self, @candidate_dirs ) = @_;
|
||||||
return $self->{dir} if $self->{dir} and ! @candidate_dirs;
|
return $self->{dir} if $self->{dir} and ! @candidate_dirs;
|
||||||
|
Loading…
Reference in New Issue
Block a user