Changeset 16342 for trunk/DataStore/scripts/dsget
- Timestamp:
- Feb 6, 2008, 1:48:13 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/DataStore/scripts/dsget (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStore/scripts/dsget
r16301 r16342 3 3 # Copyright (C) 2006-2008 Joshua Hoblitt 4 4 # 5 # $Id: dsget,v 1.1 2 2008-02-05 04:57:10eugene Exp $5 # $Id: dsget,v 1.13 2008-02-06 23:48:13 eugene Exp $ 6 6 7 7 use strict; … … 51 51 } 52 52 53 # if ($uriVolume) {54 # print "uriVolume: $uriVolume\n";55 # }56 # if ($uriFilename) {57 # print "uriFilename: $uriFilename\n";58 # }59 60 53 if ($volume and $uriVolume and ($volume ne $uriVolume)) { 61 54 die "conflicting volume names specified"; … … 65 58 if ($uriFilename) { $filename = $uriFilename; } 66 59 67 # if ($volume) { 68 # print "volume: $volume\n"; 69 # } else { 70 # print "volume undefined\n"; 71 # } 72 # print "filename: $filename\n"; 73 # if ($nebulous) { 74 # print "using nebulous\n"; 75 # } 60 # XXX EAM : should not need parse_neb_key, but how to handle case 61 # where we supply --volume and neb://volume/path ? 62 # 1) parse anyway and check for conflict 63 # 2) drop --volume option 76 64 77 65 my %p = ( … … 83 71 $p{md5sum} = $md5 if defined $md5; 84 72 85 my $dirname = dirname($filename); 86 87 if (!-d $dirname) { 73 my $tmp; 74 75 if (!$nebulous) { 76 88 77 # create path and possibly fix up permissions 89 mkpath([$dirname], 1, 0775); 90 } 91 92 # can we truely write to filename? 93 { 94 # open file for read/write but not create 95 my $fh; 96 if (open($fh, '+<', $filename)) { 97 # do nothing and fall through 98 } elsif (open($fh, '>>', $filename)) { 99 # this is the "stomp on it behavior" this probably shouldn't be the 100 # default and it may make sense to check the md5sum/bytes count of the 101 # files that's already in place to see if we really need to re-fetch it 102 unlink $filename or die "can't unlink $filename: $!"; 103 } else { 104 die "can't write to $filename"; 78 my $dirname = dirname($filename); 79 if (!-d $dirname) { 80 mkpath([$dirname], 1, 0775); 105 81 } 106 } 107 108 my $tmp = File::Temp->new( 109 DIR => $dirname, 110 TEMPLATE => '.' . basename($filename) . '.XXXXXXXX', 111 SUFFIX => '.tmp', 112 UNLINK => 1, 113 ); 82 83 # can we truly write to filename? 84 { 85 # open file for read/write but not create 86 my $fh; 87 if (open($fh, '+<', $filename)) { 88 # do nothing and fall through 89 } elsif (open($fh, '>>', $filename)) { 90 # this is the "stomp on it behavior" this probably shouldn't be the 91 # default and it may make sense to check the md5sum/bytes count of the 92 # files that's already in place to see if we really need to re-fetch it 93 unlink $filename or die "can't unlink $filename: $!"; 94 } else { 95 die "can't write to $filename"; 96 } 97 } 98 99 # for non-neb files, use the download directory for the tmp file 100 $tmp = File::Temp->new( 101 DIR => $dirname, 102 TEMPLATE => '.' . basename($filename) . '.XXXXXXXX', 103 SUFFIX => '.tmp', 104 UNLINK => 1, 105 ); 106 } else { 107 # for neb files, use /tmp for the tmp file 108 $tmp = File::Temp->new( 109 DIR => '/tmp', 110 TEMPLATE => basename($filename) . '.XXXXXXXX', 111 SUFFIX => '.tmp', 112 UNLINK => 1, 113 ); 114 } 114 115 115 116 my $tmpfilename = $tmp->filename; 116 117 print "downloading file to $tmpfilename\n"; 118 119 # request the file from the remote data store server (save in tmpfilename) 117 120 my $response = DataStore::File->new(%p)->request( filename => $tmpfilename ); 118 121
Note:
See TracChangeset
for help on using the changeset viewer.
