IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18535


Ignore:
Timestamp:
Jul 15, 2008, 9:57:05 AM (18 years ago)
Author:
bills
Message:

Changes to dsreg. Remove --fileset argument get the value from the --add
or --del option. (I kept getting it wrong this way so I changed it).

Added --force like (rm -f) the only effect of which is to not return an
error if an attempt is made to delete a non-existent fileset.

Change the file list format to allow the values for file size and md5sum
to be provided. If they are left blank, we calcluate them as before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStoreServer/scripts/dsreg

    r17948 r18535  
    4646my $del;
    4747my $remove;
     48my $force;          # on --del don't return error if fileset doesn't exist
    4849
    4950my $verbose = 0;
     
    5556
    5657GetOptions(
    57         'add         =>      \$add,
    58         'del         =>      \$del,
     58        'add=s'         =>      \$add,
     59        'del=s'         =>      \$del,
    5960        'product=s'     =>      \$product,
    60         'fileset=s'     =>      \$fileset,
    6161        'list=s'        =>      \$filelist,
    6262        'type=s'        =>      \$fstype,
     
    6666        'copy'          =>      \$copyfiles,
    6767        'rm'            =>      \$remove,
     68        'force'         =>      \$force,
    6869        'ps0=s'         =>      \$ps0,          # product specific columns 0 - 7
    6970        'ps1=s'         =>      \$ps1,
     
    8283
    8384$err .= "--product is required\n" unless defined $product;
    84 $err .= "--fileset is required\n" unless defined $fileset;
    85 
    8685
    8786# will exit if neither --add and --del is specified or if they both are specified
     
    9089
    9190if ($add) {
     91    $fileset = $add;
    9292    $err .= "--type is required\n" unless defined $fstype;
    9393    $err .= "--list is required\n" unless defined $filelist;
     
    101101        $err .= "datapath must begin with / when using --link\n";
    102102    }
     103} else {
     104    $fileset = $del;
    103105}
    104106
     
    169171    if (!$fs_row) {
    170172        print STDERR "Fileset '$fileset' not found under $product.\n";
    171         exit 1;
     173        if ($force) {
     174            exit 0;
     175        } else {
     176            exit 1;
     177        }
    172178    }
    173179    $stmt->finish();
     
    259265
    260266        my $filename;
     267        my $bytes;
     268        my $md5sum;
    261269        my $filetype;
    262270
    263271        my @fields = split /\|/;
    264         if (@fields < 2) {
     272        if (@fields < 4) {
    265273            die "malformed input line at $filelist line $lineno: $_\n";
    266274        }
    267275        $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
    268278        $filetype = shift @fields;
    269279
     
    276286        my $hashref = {
    277287            'file'      => $filename,
     288            'bytes'     => $bytes,
     289            'md5sum'    => $md5sum,
    278290            'type'      => $filetype,
    279291            'ts_cols'   => $ts_cols,
     
    321333    }
    322334
    323     # now calculate the md5sum and file size
     335    # now calculate the md5sum and file size if they weren't provided
    324336    foreach my $file (@files) {
    325337        my $filename = fileparse($file->{file}, ());
    326338        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        }
    337353    }
    338354
Note: See TracChangeset for help on using the changeset viewer.