File Coverage

blib/lib/Mail/SpamAssassin/BayesStore/SDBM.pm
Criterion Covered Total %
statement 25 33 75.7
branch 2 4 50.0
condition n/a
subroutine 9 12 75.0
pod 1 4 25.0
total 37 53 69.8


line stmt bran cond sub pod time code
1             # <@LICENSE>
2             # Licensed to the Apache Software Foundation (ASF) under one or more
3             # contributor license agreements. See the NOTICE file distributed with
4             # this work for additional information regarding copyright ownership.
5             # The ASF licenses this file to you under the Apache License, Version 2.0
6             # (the "License"); you may not use this file except in compliance with
7             # the License. You may obtain a copy of the License at:
8             #
9             # http://www.apache.org/licenses/LICENSE-2.0
10             #
11             # Unless required by applicable law or agreed to in writing, software
12             # distributed under the License is distributed on an "AS IS" BASIS,
13             # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14             # See the License for the specific language governing permissions and
15             # limitations under the License.
16             # </@LICENSE>
17              
18             package Mail::SpamAssassin::BayesStore::SDBM;
19              
20 2     2   15 use strict;
  2         5  
  2         61  
21 2     2   11 use warnings;
  2         3  
  2         53  
22             # use bytes;
23 2     2   10 use re 'taint';
  2         5  
  2         54  
24 2     2   12 use Fcntl;
  2         3  
  2         513  
25              
26 2     2   685 use Mail::SpamAssassin::BayesStore::DBM;
  2         6  
  2         61  
27 2     2   14 use Mail::SpamAssassin::Logger;
  2         4  
  2         564  
28              
29             # our @DBNAMES; # <---- unused!
30             our @ISA = qw( Mail::SpamAssassin::BayesStore::DBM );
31              
32             sub HAS_DBM_MODULE {
33 42     42 0 90 my ($self) = @_;
34 42 100       136 if (exists($self->{has_dbm_module})) {
35 36         170 return $self->{has_dbm_module};
36             }
37 6         12 $self->{has_dbm_module} = eval { require SDBM_File; };
  6         93  
38             }
39              
40             sub DBM_MODULE {
41 113     113 0 3213 return "SDBM_File";
42             }
43              
44             # Possible file extensions used by the kinds of database files SDBM_File
45             # might create. We need these so we can create a new file and rename
46             # it into place.
47             sub DB_EXTENSIONS {
48 44     44 0 202 return ('.pag', '.dir');
49             }
50              
51             sub _unlink_file {
52 0     0     my ($self, $filename) = @_;
53              
54 0           for my $ext ($self->DB_EXTENSIONS) {
55 0           unlink $filename . $ext;
56             }
57             }
58              
59             sub _rename_file {
60 0     0     my ($self, $sourcefilename, $targetfilename) = @_;
61              
62 0           for my $ext ($self->DB_EXTENSIONS) {
63 0 0         return 0 unless (rename($sourcefilename . $ext, $targetfilename . $ext));
64             }
65 0           return 1;
66             }
67              
68             # this is called directly from sa-learn(1).
69             sub perform_upgrade {
70              
71 0     0 1   return 1;
72             }
73              
74              
75             1;