IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4638


Ignore:
Timestamp:
Jul 27, 2005, 5:48:41 PM (21 years ago)
Author:
jhoblitt
Message:

->open( $foo, 'write') is not allowed when object has multiple instances

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/t/18_client_open.t

    r4440 r4638  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 18_client_open.t,v 1.2 2005-06-30 02:35:06 jhoblitt Exp $
     5# $Id: 18_client_open.t,v 1.3 2005-07-28 03:48:41 jhoblitt Exp $
    66
    77use strict;
     
    1010use Apache::Test qw( -withtestmore );
    1111
    12 plan tests => 7;
     12plan tests => 8;
    1313
    1414use lib qw( ./t ./lib );
     
    6868Test::Nebulous->setup;
    6969
     70{
     71    my $neb = Nebulous::Client->new(
     72        proxy => "http://$hostport/nebulous",
     73    );
     74    $neb->create( "foo" );
     75    $neb->replicate( "foo" );
     76
     77    is( $neb->open( "foo", 'write' ), undef,
     78        "write to object with multiple instances" );
     79}
     80
     81Test::Nebulous->setup;
     82
    7083eval {
    7184    my $neb = Nebulous::Client->new(
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r4633 r4638  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Client.pm,v 1.17 2005-07-28 01:40:26 jhoblitt Exp $
     3# $Id: Client.pm,v 1.18 2005-07-28 03:48:41 jhoblitt Exp $
    44
    55package Nebulous::Client;
     
    161161    }
    162162
    163     my $fh  = $self->open( $key, 'write' );
     163    my $fh  = $self->open( $key, 'read' );
    164164    unless ( $fh ) {
    165165        $log->debug( "can't open $key" );
     
    435435
    436436    if ( $type eq 'write' ) {
     437        my $num_instances = scalar @$locations;
     438
     439        if ( $num_instances > 1 ) {
     440            $log->warn( "write not allowed with multiple instances" );
     441            $log->debug( "leaving" );
     442            return undef;
     443        }
     444
    437445        eval {
    438446            $fh = _get_filehandle( $path, '+<' );
  • trunk/Nebulous/t/18_client_open.t

    r4440 r4638  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 18_client_open.t,v 1.2 2005-06-30 02:35:06 jhoblitt Exp $
     5# $Id: 18_client_open.t,v 1.3 2005-07-28 03:48:41 jhoblitt Exp $
    66
    77use strict;
     
    1010use Apache::Test qw( -withtestmore );
    1111
    12 plan tests => 7;
     12plan tests => 8;
    1313
    1414use lib qw( ./t ./lib );
     
    6868Test::Nebulous->setup;
    6969
     70{
     71    my $neb = Nebulous::Client->new(
     72        proxy => "http://$hostport/nebulous",
     73    );
     74    $neb->create( "foo" );
     75    $neb->replicate( "foo" );
     76
     77    is( $neb->open( "foo", 'write' ), undef,
     78        "write to object with multiple instances" );
     79}
     80
     81Test::Nebulous->setup;
     82
    7083eval {
    7184    my $neb = Nebulous::Client->new(
Note: See TracChangeset for help on using the changeset viewer.