ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/CFDB.pm
(Generate patch)

Comparing deliantra/server/ext/CFDB.pm (file contents):
Revision 1.1 by root, Fri Dec 15 19:29:18 2006 UTC vs.
Revision 1.2 by root, Wed Dec 5 11:08:34 2007 UTC

30 %arg, 30 %arg,
31 }, $class; 31 }, $class;
32 32
33 $self->{last_check} = (-M $self->{db_file}) + 1; 33 $self->{last_check} = (-M $self->{db_file}) + 1;
34 unless (-e $self->{db_file}) { 34 unless (-e $self->{db_file}) {
35 write_file ($self->{db_file}, cf::to_json ({})); 35 write_file ($self->{db_file}, cf::encode_json ({}));
36 } 36 }
37 $self->check_maildb (); 37 $self->check_maildb ();
38 38
39 $self; 39 $self;
40} 40}
43 my ($self) = @_; 43 my ($self) = @_;
44 44
45 if ($self->{last_check} > (-M $self->{db_file})) { 45 if ($self->{last_check} > (-M $self->{db_file})) {
46 $self->{last_check} = -M $self->{db_file}; 46 $self->{last_check} = -M $self->{db_file};
47 47
48 my $maildb = eval { my $m = cf::from_json read_file $self->{db_file}; return $m }; 48 my $maildb = eval { my $m = cf::decode_json read_file $self->{db_file}; return $m };
49 if ($@) { 49 if ($@) {
50 warn "ERROR when reading mail database $self->{db_file}: $@\n"; 50 warn "ERROR when reading mail database $self->{db_file}: $@\n";
51 $self->{db_file} = $self->{db_file} . ".after_failure"; 51 $self->{db_file} = $self->{db_file} . ".after_failure";
52 } else { 52 } else {
53 $self->{maildb} = $maildb; 53 $self->{maildb} = $maildb;
59# XXX: A second process will (of course) terribly damage the maildatabase 59# XXX: A second process will (of course) terribly damage the maildatabase
60# but i assume there wont be any second process. 60# but i assume there wont be any second process.
61sub sync_maildb { 61sub sync_maildb {
62 my ($self) = @_; 62 my ($self) = @_;
63 63
64 write_file ($self->{db_file}, cf::to_json ($self->{maildb})); 64 write_file ($self->{db_file}, cf::encode_json ($self->{maildb}));
65 $self->{last_check} = -M $self->{db_file}; 65 $self->{last_check} = -M $self->{db_file};
66} 66}
67 67
68sub get { 68sub get {
69 my ($self, $key) = @_; 69 my ($self, $key) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines