Changeset 17448
- Timestamp:
- Apr 17, 2008, 2:08:23 PM (18 years ago)
- Location:
- trunk/Nebulous
- Files:
-
- 4 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Client.pm (modified) (4 diffs)
-
lib/Nebulous/Client.pod (modified) (1 diff)
-
t/58_client_open.t (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/Changes
r17081 r17448 1 1 Revision history for Nebulous 2 3 0.08 4 - add Nebulous::Client::open() '>' (truncate) mode 2 5 3 6 0.07 -
trunk/Nebulous/lib/Nebulous/Client.pm
r17081 r17448 1 1 # Copyright (c) 2004-2008 Joshua Hoblitt 2 2 # 3 # $Id: Client.pm,v 1.4 1 2008-03-21 01:53:36jhoblitt Exp $3 # $Id: Client.pm,v 1.42 2008-04-18 00:08:23 jhoblitt Exp $ 4 4 5 5 package Nebulous::Client; … … 503 503 type => SCALAR, 504 504 callbacks => { 505 'is read or write' => sub { $_[0] =~ /^(?:read|write )$/ },505 'is read or write' => sub { $_[0] =~ /^(?:read|write|>)$/ }, 506 506 }, 507 507 }, … … 538 538 } 539 539 540 if ( $type eq 'write' ) {540 if ( $type eq 'write' or $type eq '>' ) { 541 541 my $num_instances = scalar @$locations; 542 542 … … 551 551 }; 552 552 $log->logdie( $@ ) if $@; 553 554 if ($type eq '>') { 555 truncate($fh, 0) or $log->logdie("truncate failed: $!"); 556 } 553 557 } elsif ( $type eq 'read' ) { 554 558 eval { -
trunk/Nebulous/lib/Nebulous/Client.pod
r17081 r17448 285 285 =item * type 286 286 287 The type of lock to acquire. Either C<read> or C<write>. 287 The type of lock to acquire. One of [C<read>, C<write>, C<>>]. 288 289 C<>> truncates any pre-existing files to zero length and opens it for writing. 288 290 289 291 =back -
trunk/Nebulous/t/58_client_open.t
r5667 r17448 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 58_client_open.t,v 1. 1 2005-12-03 02:52:31jhoblitt Exp $5 # $Id: 58_client_open.t,v 1.2 2008-04-18 00:08:23 jhoblitt Exp $ 6 6 7 7 use strict; … … 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 8;12 plan tests => 10; 13 13 14 14 use lib qw( ./t ./lib ); … … 17 17 use Nebulous::Util qw( :standard ); 18 18 use Test::Nebulous; 19 use File::stat; 19 20 20 21 my $hostport = Apache::Test->config->{ 'hostport' }; … … 68 69 Test::Nebulous->setup; 69 70 71 # truncation test 72 { 73 my $neb = Nebulous::Client->new( 74 proxy => "http://$hostport/nebulous", 75 ); 76 my $fh = $neb->open( "foo", 'write' ); 77 print $fh "foobar"; 78 close $fh; 79 80 $fh = $neb->open( "foo", '>' ); 81 ok($fh, "open in trucate mode" ); 82 my $sb = stat($fh); 83 is($sb->size, 0, "file was truncated"); 84 } 85 86 Test::Nebulous->setup; 87 70 88 { 71 89 my $neb = Nebulous::Client->new(
Note:
See TracChangeset
for help on using the changeset viewer.
