ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/URL/URLhandler.pm
(Generate patch)

Comparing COMP/SCRAM/src/URL/URLhandler.pm (file contents):
Revision 1.10 by williamc, Mon Nov 15 16:50:00 1999 UTC vs.
Revision 1.11 by williamc, Wed Nov 17 19:14:38 1999 UTC

# Line 2 | Line 2
2   # Interface
3   # ---------
4   # new(cache)       : A new urlhandler with a defined default cahce directory
5 + # download(url,[location]) : as get but always download
6   # get(url,[location]) : download from the specified url to cache or location
7   #                       return the full url path name incl. any base expansion
8   #                       and the filename downloaded to
# Line 51 | Line 52 | sub init {
52   sub get {
53          my $self=shift;
54          my $origurl=shift;
55 +        my $file="";
56  
57 <        # Process the URL string
58 <        $url=URL::URLclass->new($origurl);
57 >        my $url=URL::URLclass->new($origurl);
58 >        my $type=$url->type();
59 >        $url->expandurl($self->currentbase($type));
60 >        my $fullurl=$url->url();
61 >
62 >        my $location=$self->{cache}->file($fullurl);
63 >        if ( $location ne "" ) {
64 >          $file=$self->{cache}->file($location);
65 >          #print " Already defined file --".$location." -- ".$file."\n";
66 >        }
67 >        else {
68 >          ($fullurl,$file)=$self->download($origurl, @_);
69 >        }
70 >        return ($fullurl, $file);
71 > }
72 >
73 > sub download {
74 >        my $self=shift;
75 >        my $origurl=shift;
76 >
77 >        print "downloading $origurl\n";
78 >        # Process the URL string
79 >        my $url=URL::URLclass->new($origurl);
80          my $type=$url->type();
81          $urltypehandler=$self->_typehandler($type);
82          $url->expandurl($self->currentbase($type));
# Line 65 | Line 88 | sub get {
88          else {
89             $location=$self->{cache}->filename($url->url());
90          }
91 <        # -- get the file form the appropriate handler
91 >        # -- get the file from the appropriate handler
92          if ( defined $urltypehandler ) {
93               # Call the download module
94               $file=eval{$urltypehandler->get($url, $location)};
# Line 73 | Line 96 | sub get {
96  
97          # now register it in the cache if successful
98          if ( $file ) {
99 <          $self->{cache}->store($url->url(), $file);
99 >          $self->{cache}->store($url->url(), $location);
100 >          $self->{cache}->store($location, $file);
101          }
102          return ($url->url(), $file);
103   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines