Changeset 17948 for trunk/DataStoreServer/scripts/dsreg
- Timestamp:
- Jun 5, 2008, 2:17:16 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/DataStoreServer/scripts/dsreg (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStoreServer/scripts/dsreg
r17895 r17948 15 15 use PS::IPP::Metadata::List qw( parse_md_list ); 16 16 use File::Copy; 17 use File::Basename; 17 18 18 19 use PS::IPP::Config qw($PS_EXIT_SUCCESS … … 37 38 my $copyfiles; # if set, copy files from this directory to the Data Store fileset 38 39 my $datapath; # source for files required if $linkfiles or $copyfiles 40 my $abspath; # Path specified is absolute 39 41 40 42 my $dbname; # Database name … … 60 62 'type=s' => \$fstype, 61 63 'datapath=s' => \$datapath, 64 'abspath' => \$abspath, 62 65 'link' => \$linkfiles, 63 66 'copy' => \$copyfiles, … … 92 95 $err .= "only one of --link and --copy is allowed\n"; 93 96 } 94 if (($linkfiles or $copyfiles) and !$datapath ) {97 if (($linkfiles or $copyfiles) and !$datapath and !$abspath) { 95 98 $err .= "need to specify datapath with --link or --copy\n"; 96 99 } … … 293 296 ## then copy or symlink the files into place 294 297 foreach my $ref (@files) { 295 my $src = "$datapath/$ref->{file}"; 296 my $dest = "$fileset_dir/$ref->{file}"; 298 my $src = (defined $abspath ? '' : "$datapath/") . "$ref->{file}"; 299 my $filename = fileparse($ref->{file}, ()); 300 my $dest = "$fileset_dir/$filename"; 297 301 298 302 if ($linkfiles) { … … 319 323 # now calculate the md5sum and file size 320 324 foreach my $file (@files) { 321 322 my $path = "$fileset_dir/$file ->{file}";325 my $filename = fileparse($file->{file}, ()); 326 my $path = "$fileset_dir/$filename"; 323 327 my @finfo = stat("$path"); 324 328 … … 364 368 365 369 foreach my $ref (@files) { 370 my $filename = fileparse($ref->{file}, ()); 366 371 my $query = "INSERT INTO dsFile" . 367 372 " (fileset_id, file_id, file_name, bytes, md5sum, type," . … … 371 376 372 377 my $aref = $ref->{ts_cols}; 373 my $do_args = [($ ref->{file}, $ref->{bytes}, $ref->{md5sum}, $ref->{type}), @$aref];378 my $do_args = [($filename, $ref->{bytes}, $ref->{md5sum}, $ref->{type}), @$aref]; 374 379 375 380 $count = $dbh->do($query, undef, @$do_args); 376 381 377 382 if ($count == 0E0) { 378 die("failed to insert $ ref->{file}into $fileset");383 die("failed to insert $filename into $fileset"); 379 384 } 380 385 }
Note:
See TracChangeset
for help on using the changeset viewer.
