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              
19             use strict;
20 2     2   14 use warnings;
  2         5  
  2         51  
21 2     2   9 # use bytes;
  2         5  
  2         46  
22             use re 'taint';
23 2     2   11 use Fcntl;
  2         2  
  2         50  
24 2     2   11  
  2         6  
  2         467  
25             use Mail::SpamAssassin::BayesStore::DBM;
26 2     2   582 use Mail::SpamAssassin::Logger;
  2         6  
  2         67  
27 2     2   13  
  2         4  
  2         538  
28             # our @DBNAMES; # <---- unused!
29             our @ISA = qw( Mail::SpamAssassin::BayesStore::DBM );
30              
31             my ($self) = @_;
32             if (exists($self->{has_dbm_module})) {
33 42     42 0 113 return $self->{has_dbm_module};
34 42 100       137 }
35 36         194 $self->{has_dbm_module} = eval { require SDBM_File; };
36             }
37 6         16  
  6         75  
38             return "SDBM_File";
39             }
40              
41 113     113 0 3361 # Possible file extensions used by the kinds of database files SDBM_File
42             # might create. We need these so we can create a new file and rename
43             # it into place.
44             return ('.pag', '.dir');
45             }
46              
47             my ($self, $filename) = @_;
48 44     44 0 162  
49             for my $ext ($self->DB_EXTENSIONS) {
50             unlink $filename . $ext;
51             }
52 0     0     }
53              
54 0           my ($self, $sourcefilename, $targetfilename) = @_;
55 0            
56             for my $ext ($self->DB_EXTENSIONS) {
57             return 0 unless (rename($sourcefilename . $ext, $targetfilename . $ext));
58             }
59             return 1;
60 0     0     }
61              
62 0           # this is called directly from sa-learn(1).
63 0 0          
64             return 1;
65 0           }
66              
67              
68             1;