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.15.2.7 by williamc, Mon Aug 28 07:03:29 2000 UTC vs.
Revision 1.21 by muzaffar, Fri Jan 14 17:36:43 2011 UTC

# Line 34 | Line 34 | sub init {
34          my $cache=shift;
35          $self->{cache}=$cache;
36          $self->{cachestore}=$self->{cache}->filestore();
37 +
38          use URL::URL_cvs;
39          use URL::URL_file;
40 <        use URL::URL_test;
40 >        use URL::URL_http;
41 >        use URL::URL_svn;
42 >
43          $self->{urlmodules}={
44                          'cvs' => 'URL::URL_cvs',
45                          'file' => 'URL::URL_file',
46 <                        'test' => 'URL::URL_test'
46 >                        'http' => 'URL::URL_http',
47 >                        'svn' => 'URL::URL_svn'
48                  };
49   }
50  
51 < sub get {
52 <        my $self=shift;
53 <        my $origurl=shift;
54 <        my $file="";
55 <
56 <        my $url=URL::URLclass->new($origurl);
57 <        my $type=$url->type();
58 <        $url->merge($self->currentbase($type));
59 <        my $fullurl=$url->url();
60 <
61 <        $file=$self->{cache}->file($fullurl);
62 <        if ( $file eq "" ) {
63 <          ($fullurl,$file)=$self->download($origurl, @_);
64 <        }
65 <        return ($fullurl, $file);
66 < }
51 > sub get
52 >   {
53 >   my $self=shift;
54 >   my $origurl=shift;
55 >   my $file="";
56 >  
57 >   my $url=URL::URLclass->new($origurl);
58 >   my $type=$url->type();
59 >   $url->merge($self->currentbase($type));
60 >   my $fullurl=$url->url();
61 >  
62 >   $file=$self->{cache}->file($fullurl);
63 >   if ( $file eq "" )
64 >      {
65 >      ($fullurl,$file)=$self->download($origurl, @_);
66 >      if (-f $file)
67 >         {
68 >         my $filemode = 0644;   chmod $filemode, $file;
69 >         }
70 >      }
71 >   return ($fullurl, $file);
72 >   }
73  
74   sub download {
75          my $self=shift;
# Line 70 | Line 80 | sub download {
80          my $type=$url->type();
81          $urltypehandler=$self->_typehandler($type);
82          $url->merge($self->currentbase($type));
73        #print "Attempting download of ".$url->url()."\n";
83  
84          # Generate a location name if not provided
85          my $nocache=1;
# Line 90 | Line 99 | sub download {
99          # now register it in the cache if successful
100          if ( $file ne "" ) {
101           if ( $file && $nocache) {
93          #$self->{cache}->store($url->url(), $location);
102            $self->{cache}->store($url->url(), $file);
103           }
104          }
# Line 169 | Line 177 | sub _typehandler {
177  
178          $self->checktype($type);
179  
180 <        # instantiate only if it dosnt already exist;
180 >        # instantiate only if it doesnt already exist;
181          if ( exists $self->{'urlobjs'}{$type} ) {
182                  $self->{'urlobjs'}{$type};
183          }      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines