line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::KDBX::Transaction; |
2
|
|
|
|
|
|
|
# ABSTRACT: Make multiple database edits atomically |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
63
|
|
5
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
36
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
10
|
use Devel::GlobalDestruction; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
8
|
2
|
|
|
2
|
|
124
|
use File::KDBX::Util qw(:class); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
243
|
|
9
|
2
|
|
|
2
|
|
13
|
use namespace::clean; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.906'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
16
|
|
|
16
|
1
|
25
|
my $class = shift; |
16
|
16
|
|
|
|
|
22
|
my $object = shift; |
17
|
16
|
|
|
|
|
48
|
$object->begin_work(@_); |
18
|
16
|
|
|
|
|
65
|
return bless {object => $object}, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
16
|
50
|
|
16
|
1
|
1819
|
sub DESTROY { !in_global_destruction and $_[0]->rollback } |
|
16
|
50
|
|
16
|
|
49
|
|
22
|
|
|
|
|
|
|
|
23
|
16
|
|
50
|
|
|
42
|
|
24
|
|
|
|
|
|
|
has 'object', is => 'ro'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub commit { |
28
|
12
|
|
|
12
|
1
|
37
|
my $self = shift; |
29
|
12
|
50
|
|
|
|
42
|
return if $self->{done}; |
30
|
|
|
|
|
|
|
|
31
|
12
|
|
|
|
|
27
|
my $obj = $self->object; |
32
|
12
|
|
|
|
|
42
|
$obj->commit; |
33
|
12
|
|
|
|
|
65
|
$self->{done} = 1; |
34
|
12
|
|
|
|
|
33
|
return $obj; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub rollback { |
39
|
17
|
|
|
17
|
1
|
114
|
my $self = shift; |
40
|
17
|
100
|
|
|
|
70
|
return if $self->{done}; |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
8
|
my $obj = $self->object; |
43
|
4
|
|
|
|
|
14
|
$obj->rollback; |
44
|
4
|
|
|
|
|
17
|
$self->{done} = 1; |
45
|
4
|
|
|
|
|
13
|
return $obj; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |