=================================================================== RCS file: /cvs/openbsd/OpenBSDTorrents/lib/BT/MetaInfo/Cached.pm,v retrieving revision 1.5 retrieving revision 1.7 diff -u -r1.5 -r1.7 --- openbsd/OpenBSDTorrents/lib/BT/MetaInfo/Cached.pm 2005/05/05 21:08:04 1.5 +++ openbsd/OpenBSDTorrents/lib/BT/MetaInfo/Cached.pm 2005/05/05 21:29:13 1.7 @@ -1,4 +1,4 @@ -# $Id: Cached.pm,v 1.5 2005/05/05 20:08:04 andrew Exp $ +# $Id: Cached.pm,v 1.7 2005/05/05 20:29:13 andrew Exp $ use strict; package BT::MetaInfo::Cached; @@ -6,21 +6,14 @@ require 5.6.0; use vars qw( $VERSION @ISA ); -use YAML; - -#use Digest::SHA1 qw(sha1); -#use YAML qw/ DumpFile LoadFile /; - use Cache::FileCache; use File::Basename; use BT::MetaInfo; use base 'BT::MetaInfo'; -#use OpenBSDTorrents; +$VERSION = do { my @r = (q$Id: Cached.pm,v 1.7 2005/05/05 20:29:13 andrew Exp $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; -$VERSION = do { my @r = (q$Id: Cached.pm,v 1.5 2005/05/05 20:08:04 andrew Exp $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; - sub new { my $class = shift; @@ -38,16 +31,6 @@ return(bless($obj, $class)); } -sub save { - my ($self, $file) = @_; - my $basename = basename($file); - - $self->SUPER::save($file, @_); - - my %info_hash = %$self; # unbless - $self->cache->set->($basename, \%info_hash) -} - sub _load { my $file = shift; my $cache = shift; @@ -63,39 +46,14 @@ return $info; } -#sub cached -#{ -# my $self = shift; -# my $which_info = shift; -# my $file = shift; -# my @args = @_; -# -# if (@args) { -# return $self->$which_info(@args), -# } -# -# return undef unless $which_info; -# return $self->$which_info unless $file; -# -# my $info = undef; -# -# if (-e $file) { -# #print "Reading meta file: $file\n"; -# $info = LoadFile($file); -# } -# -# unless ($info->{$which_info}) { -# my $cur_info = $self->$which_info; -# -# $info->{$which_info} = $cur_info; -# DumpFile($file, $info); -# } -# -# if (defined $info->{$which_info}) { -# return $info->{$which_info}; -# } else { -# return $self->$which_info; -# } -#} -1 +sub save +{ + my ($self, $file) = @_; + my $basename = basename($file); + + $self->SUPER::save($file, @_); + + my %info_hash = %$self; # unbless + $self->cache->set->($basename, \%info_hash) +}