IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19602


Ignore:
Timestamp:
Sep 18, 2008, 1:39:36 PM (18 years ago)
Author:
jhoblitt
Message:

add --copies option to dsget

Location:
trunk/DataStore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStore/Changes

    r17770 r19602  
    22
    330.08
     4    - add --copies option to dsget
    45    - have dsget set "user.copies" xattr on files downloaded into Nebulous
    56    - change dsget to flush() & sync() downloaded files
  • trunk/DataStore/scripts/dsget

    r17774 r19602  
    33# Copyright (C) 2006-2008  Joshua Hoblitt
    44#
    5 # $Id: dsget,v 1.30 2008-05-22 20:04:46 jhoblitt Exp $
     5# $Id: dsget,v 1.31 2008-09-18 23:39:36 jhoblitt Exp $
    66
    77use strict;
     
    2121my ($uri,
    2222    $bytes,
     23    $copies,
    2324    $md5,
    2425    $nebulous,
     
    3536    'uri|u=s'       => \$uri,
    3637    'bytes|m=s'     => \$bytes,
     38    'copies=d'      => \$copies,
    3739    'nebulous|n'    => \$nebulous,
    3840    'volume|v=s'    => \$volume,
     
    6163    $nebulous ||=1;
    6264}
     65
     66if (defined $copies) {
     67    if (not defined $nebulous) {
     68        warn "--copies is meanless without --nebulous or --volume";
     69        undef $copies;
     70    }
     71    if ($copies < 1) {
     72        die "--copies must be >= 1";
     73    }
     74}
    6375
    6476if ($compress) {
     
    178190    $fh->sync or die "can't sync nebulous filehandle: $!";
    179191    close($fh) or die "can't close nebulous filehandle: $!";
     192
     193    # make any required copies
     194    if (defined $copies and $copies > 1) {
     195        foreach (1 .. ($copies - 1)) {
     196            $neb->replicate($filename)
     197                or die "failed to replicate $filename failed: $!";
     198        }
     199    }
    180200} else {
    181201    $tmp->flush or die "can't flush filehandle: $!";
     
    200220
    201221    dsget --uri <uri> --filename <filename> [--bytes <nbytes>] [--md5 <hex>]
    202         [--compress] [--nebulous] [--volume <volume name>]
     222        [--compress] [--nebulous] [--volume <volume name>] [--copies <n>]
    203223
    204224=head1 DESCRIPTION
     
    251271The ammount of time (in seconds) to wait for a response from the DataStore
    252272after making an HTTP request.  The default is 30s.
     273
     274Optional.
     275
     276=item * --copies <n>
     277
     278If C<--nebulous> is in use, the number of Nebulous replications to make.
    253279
    254280Optional.
Note: See TracChangeset for help on using the changeset viewer.