From: rkinyon Date: Thu, 23 Feb 2006 15:12:51 +0000 (+0000) Subject: Fixed missing inode problem X-Git-Tag: 0-97~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bd7739133ff85e9bd7c1dd8fdda402c5c2ff839a;p=dbsrgits%2FDBM-Deep.git Fixed missing inode problem --- diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index e9f89cf..dc618ce 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -254,12 +254,10 @@ sub _open { if (!$bytes_read) { seek($fh, 0, SEEK_SET); print($fh SIG_FILE); - $self->root->{end} = length(SIG_FILE); $self->_create_tag($self->base_offset, $self->type, chr(0) x $INDEX_SIZE); my $plain_key = "[base]"; print($fh pack($DATA_LENGTH_PACK, length($plain_key)) . $plain_key ); - $self->root->{end} += $DATA_LENGTH_SIZE + length($plain_key); # Flush the filehandle my $old_fh = select $fh; @@ -268,6 +266,10 @@ sub _open { $| = $old_af; select $old_fh; + my @stats = stat($fh); + $self->root->{inode} = $stats[1]; + $self->root->{end} = $stats[7]; + return 1; } diff --git a/t/07_locking.t b/t/07_locking.t index 7ea255e..58ea83f 100644 --- a/t/07_locking.t +++ b/t/07_locking.t @@ -2,16 +2,15 @@ # DBM::Deep Test ## use strict; -use Test; -BEGIN { plan tests => 2 } +use Test::More tests => 3; -use DBM::Deep; +use_ok( 'DBM::Deep' ); ## # basic file open ## unlink "t/test.db"; -my $db = new DBM::Deep( +my $db = DBM::Deep->new( file => "t/test.db", locking => 1 ); @@ -23,19 +22,12 @@ if ($db->error()) { # basic put/get ## $db->{key1} = "value1"; -ok( $db->{key1} eq "value1" ); +is( $db->{key1}, "value1", "key1 is set" ); ## # explicit lock ## -$db->lock( DBM::Deep::LOCK_EX ); +$db->lock( DBM::Deep->LOCK_EX ); $db->{key1} = "value2"; $db->unlock(); -ok( $db->{key1} eq "value2" ); - -## -# close, delete file, exit -## -undef $db; -unlink "t/test.db"; -exit(0); +is( $db->{key1}, "value2", "key1 is overridden" );