Changeset 17450 for trunk/DataStore/scripts/dsget
- Timestamp:
- Apr 17, 2008, 2:35:35 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/DataStore/scripts/dsget (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStore/scripts/dsget
r16368 r17450 3 3 # Copyright (C) 2006-2008 Joshua Hoblitt 4 4 # 5 # $Id: dsget,v 1.1 4 2008-02-08 19:30:38 eugeneExp $5 # $Id: dsget,v 1.15 2008-04-18 00:35:35 jhoblitt Exp $ 6 6 7 7 use strict; … … 83 83 my $dirname = dirname($filename); 84 84 if (!-d $dirname) { 85 mkpath([$dirname], 1, 0775);85 mkpath([$dirname], 1, 0775); 86 86 } 87 87 88 88 # can we truly write to filename? 89 { 90 # open file for read/write but not create 91 my $fh; 92 if (open($fh, '+<', $filename)) { 93 # do nothing and fall through 94 } elsif (open($fh, '>>', $filename)) { 95 # this is the "stomp on it behavior" this probably shouldn't be the 96 # default and it may make sense to check the md5sum/bytes count of the 97 # files that's already in place to see if we really need to re-fetch it 98 unlink $filename or die "can't unlink $filename: $!"; 99 } else { 100 die "can't write to $filename"; 101 } 89 { 90 # open file for read/write but not create 91 my $fh; 92 if (open($fh, '+<', $filename)) { 93 # do nothing and fall through 94 } elsif (open($fh, '>>', $filename)) { 95 # this is the "stomp on it behavior" this probably shouldn't be the 96 # default and it may make sense to check the md5sum/bytes count of the 97 # files that's already in place to see if we really need to re-fetch it 98 unlink $filename or die "can't unlink $filename: $!"; 99 } else { 100 die "can't write to $filename"; 102 101 } 102 } 103 103 104 104 # for non-neb files, use the download directory for the tmp file 105 105 $tmp = File::Temp->new( 106 DIR => $dirname,107 TEMPLATE => '.' . basename($filename) . '.XXXXXXXX',108 SUFFIX => '.tmp',109 UNLINK => 1,110 );106 DIR => $dirname, 107 TEMPLATE => '.' . basename($filename) . '.XXXXXXXX', 108 SUFFIX => '.tmp', 109 UNLINK => 1, 110 ); 111 111 } else { 112 112 # for neb files, use /tmp for the tmp file 113 113 $tmp = File::Temp->new( 114 DIR => '/tmp',115 TEMPLATE => basename($filename) . '.XXXXXXXX',116 SUFFIX => '.tmp',117 UNLINK => 1,118 );114 DIR => '/tmp', 115 TEMPLATE => basename($filename) . '.XXXXXXXX', 116 SUFFIX => '.tmp', 117 UNLINK => 1, 118 ); 119 119 } 120 120 … … 144 144 unless defined $neb; 145 145 146 # XXX see comment above and not blindly stomping 147 # if the key doesn't already exist then create it 148 # if it does, delete it so that we end up on the right storage volume 149 if ($neb->stat($filename)) { 150 $neb->delete($filename) 151 or die "Nebulous can't delete key $filename"; 152 } 153 146 154 my $fh = $neb->open_create( $filename, $volume ) 147 155 or die "Nebulous can't create key $filename"; 156 148 157 open(my $src_fh, $tmpfilename) or die "can't open file $tmpfilename: $!"; 149 158
Note:
See TracChangeset
for help on using the changeset viewer.
