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
|
|
|
|
|
59
|
|
5
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
36
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
8
|
use Devel::GlobalDestruction; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
8
|
2
|
|
|
2
|
|
113
|
use File::KDBX::Util qw(:class); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
195
|
|
9
|
2
|
|
|
2
|
|
11
|
use namespace::clean; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
22
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.905'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
16
|
|
|
16
|
1
|
24
|
my $class = shift; |
16
|
16
|
|
|
|
|
19
|
my $object = shift; |
17
|
16
|
|
|
|
|
47
|
$object->begin_work(@_); |
18
|
16
|
|
|
|
|
63
|
return bless {object => $object}, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
16
|
50
|
|
16
|
1
|
1777
|
sub DESTROY { !in_global_destruction and $_[0]->rollback } |
|
16
|
50
|
|
16
|
|
45
|
|
22
|
|
|
|
|
|
|
|
23
|
16
|
|
50
|
|
|
41
|
|
24
|
|
|
|
|
|
|
has 'object', is => 'ro'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub commit { |
28
|
12
|
|
|
12
|
1
|
36
|
my $self = shift; |
29
|
12
|
50
|
|
|
|
32
|
return if $self->{done}; |
30
|
|
|
|
|
|
|
|
31
|
12
|
|
|
|
|
28
|
my $obj = $self->object; |
32
|
12
|
|
|
|
|
39
|
$obj->commit; |
33
|
12
|
|
|
|
|
55
|
$self->{done} = 1; |
34
|
12
|
|
|
|
|
30
|
return $obj; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub rollback { |
39
|
17
|
|
|
17
|
1
|
123
|
my $self = shift; |
40
|
17
|
100
|
|
|
|
67
|
return if $self->{done}; |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
9
|
my $obj = $self->object; |
43
|
4
|
|
|
|
|
15
|
$obj->rollback; |
44
|
4
|
|
|
|
|
14
|
$self->{done} = 1; |
45
|
4
|
|
|
|
|
12
|
return $obj; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |