Changeset 18535
- Timestamp:
- Jul 15, 2008, 9:57:05 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/DataStoreServer/scripts/dsreg (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStoreServer/scripts/dsreg
r17948 r18535 46 46 my $del; 47 47 my $remove; 48 my $force; # on --del don't return error if fileset doesn't exist 48 49 49 50 my $verbose = 0; … … 55 56 56 57 GetOptions( 57 'add '=> \$add,58 'del '=> \$del,58 'add=s' => \$add, 59 'del=s' => \$del, 59 60 'product=s' => \$product, 60 'fileset=s' => \$fileset,61 61 'list=s' => \$filelist, 62 62 'type=s' => \$fstype, … … 66 66 'copy' => \$copyfiles, 67 67 'rm' => \$remove, 68 'force' => \$force, 68 69 'ps0=s' => \$ps0, # product specific columns 0 - 7 69 70 'ps1=s' => \$ps1, … … 82 83 83 84 $err .= "--product is required\n" unless defined $product; 84 $err .= "--fileset is required\n" unless defined $fileset;85 86 85 87 86 # will exit if neither --add and --del is specified or if they both are specified … … 90 89 91 90 if ($add) { 91 $fileset = $add; 92 92 $err .= "--type is required\n" unless defined $fstype; 93 93 $err .= "--list is required\n" unless defined $filelist; … … 101 101 $err .= "datapath must begin with / when using --link\n"; 102 102 } 103 } else { 104 $fileset = $del; 103 105 } 104 106 … … 169 171 if (!$fs_row) { 170 172 print STDERR "Fileset '$fileset' not found under $product.\n"; 171 exit 1; 173 if ($force) { 174 exit 0; 175 } else { 176 exit 1; 177 } 172 178 } 173 179 $stmt->finish(); … … 259 265 260 266 my $filename; 267 my $bytes; 268 my $md5sum; 261 269 my $filetype; 262 270 263 271 my @fields = split /\|/; 264 if (@fields < 2) {272 if (@fields < 4) { 265 273 die "malformed input line at $filelist line $lineno: $_\n"; 266 274 } 267 275 $filename = shift @fields; 276 $bytes = shift @fields; # if this is null it will be calculated below 277 $md5sum = shift @fields; # if this is null it will be calculated below 268 278 $filetype = shift @fields; 269 279 … … 276 286 my $hashref = { 277 287 'file' => $filename, 288 'bytes' => $bytes, 289 'md5sum' => $md5sum, 278 290 'type' => $filetype, 279 291 'ts_cols' => $ts_cols, … … 321 333 } 322 334 323 # now calculate the md5sum and file size 335 # now calculate the md5sum and file size if they weren't provided 324 336 foreach my $file (@files) { 325 337 my $filename = fileparse($file->{file}, ()); 326 338 my $path = "$fileset_dir/$filename"; 327 my @finfo = stat("$path"); 328 329 unless (@finfo) { 330 die ("Line $lineno: referenced file " 331 ."($path does not exist.\n"); 332 } 333 $file->{bytes} = $finfo[7]; 334 335 # Get MD5 sum 336 $file->{md5sum} = file_md5_hex($path); 339 if (! -e $path ) { 340 die "file $path not found"; 341 } 342 if (!$file->{bytes}) { 343 my @finfo = stat($path); 344 unless (@finfo) { 345 die ("can't stat $path"); 346 } 347 $file->{bytes} = $finfo[7]; 348 } 349 if (!$file->{md5sum}) { 350 # Get MD5 sum 351 $file->{md5sum} = file_md5_hex($path); 352 } 337 353 } 338 354
Note:
See TracChangeset
for help on using the changeset viewer.
