Changeset 13269
- Timestamp:
- May 4, 2007, 3:41:29 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
Nebulous-Server/Build.PL (modified) (1 diff)
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (3 diffs)
-
Nebulous-Server/t/03_server_create_object.t (modified) (8 diffs)
-
Nebulous/Build.PL (modified) (1 diff)
-
Nebulous/lib/Nebulous/Server.pm (modified) (3 diffs)
-
Nebulous/lib/Nebulous/Util.pm (modified) (3 diffs)
-
Nebulous/t/03_server_create_object.t (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Build.PL
r13257 r13269 92 92 'Net::Server::Daemonize'=> '0.05', 93 93 'Sys::Statistics::Linux::DiskUsage' => '0.02', 94 94 'File::ExtAttr' => '1.03', 95 95 }, 96 96 build_requires => { -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r13251 r13269 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.3 8 2007-05-04 23:36:46jhoblitt Exp $3 # $Id: Server.pm,v 1.39 2007-05-05 01:41:29 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 208 208 my $filename = $key; 209 209 # mange '/'s into ':' 210 $ key=~ s|/|:|g;211 my $uri = URI::file->new("$vol_path/$ key.$ins_id");210 $filename =~ s|/|:|g; 211 my $uri = URI::file->new("$vol_path/$filename.$ins_id"); 212 212 $log->debug("generated uri $uri"); 213 213 214 214 # TODO add some stuff here to retry if unsucessful 215 215 eval { 216 _create_empty_file($uri->file );216 _create_empty_file($uri->file, $key); 217 217 }; 218 218 if ($@) { … … 361 361 } 362 362 363 my $uri = URI::file->new("$vol_path/$key.$ins_id"); 363 my $filename = $key; 364 # mange '/'s into ':' 365 $filename =~ s|/|:|g; 366 my $uri = URI::file->new("$vol_path/$filename.$ins_id"); 364 367 $log->debug("generated uri $uri"); 365 368 366 369 # TODO add some stuff here to retry if unsucessful 367 370 eval { 368 _create_empty_file($uri->file );371 _create_empty_file($uri->file, $key); 369 372 }; 370 373 if ($@) { -
trunk/Nebulous-Server/t/03_server_create_object.t
r13206 r13269 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 03_server_create_object.t,v 1.1 7 2007-05-04 00:43:44jhoblitt Exp $5 # $Id: 03_server_create_object.t,v 1.18 2007-05-05 01:41:29 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 2 2;10 use Test::More tests => 28; 11 11 12 12 use lib qw( ./t ./lib ); … … 17 17 use Test::URI; 18 18 use URI::Split qw( uri_split ); 19 use File::ExtAttr qw( getfattr ); 19 20 20 21 my $neb = Nebulous::Server->new( … … 33 34 ok(-e $path, "file exists"); 34 35 uri_scheme_ok($uri, 'file'); 36 37 is(getfattr($path, 'nebulous_key'), 'foo', 'nebulous_key xattr'); 35 38 } 36 39 … … 44 47 ok(-e $path, "file exists"); 45 48 uri_scheme_ok($uri, 'file'); 49 50 is(getfattr($path, 'nebulous_key'), '/foo', 'nebulous_key xattr'); 46 51 } 47 52 … … 55 60 ok(-e $path, "file exists"); 56 61 uri_scheme_ok($uri, 'file'); 62 63 is(getfattr($path, 'nebulous_key'), '/foo/', 'nebulous_key xattr'); 57 64 } 58 65 … … 66 73 ok(-e $path, "file exists"); 67 74 uri_scheme_ok($uri, 'file'); 75 76 is(getfattr($path, 'nebulous_key'), 'foo/', 'nebulous_key xattr'); 68 77 } 69 78 … … 77 86 ok(-e $path, "file exists"); 78 87 uri_scheme_ok($uri, 'file'); 88 89 is(getfattr($path, 'nebulous_key'), 'foo/bar', 'nebulous_key xattr'); 79 90 } 80 91 … … 88 99 ok(-e $path, "file exists"); 89 100 uri_scheme_ok($uri, 'file'); 101 102 is(getfattr($path, 'nebulous_key'), '/foo/bar', 'nebulous_key xattr'); 90 103 } 91 104 -
trunk/Nebulous/Build.PL
r13257 r13269 92 92 'Net::Server::Daemonize'=> '0.05', 93 93 'Sys::Statistics::Linux::DiskUsage' => '0.02', 94 94 'File::ExtAttr' => '1.03', 95 95 }, 96 96 build_requires => { -
trunk/Nebulous/lib/Nebulous/Server.pm
r13251 r13269 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.3 8 2007-05-04 23:36:46jhoblitt Exp $3 # $Id: Server.pm,v 1.39 2007-05-05 01:41:29 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 208 208 my $filename = $key; 209 209 # mange '/'s into ':' 210 $ key=~ s|/|:|g;211 my $uri = URI::file->new("$vol_path/$ key.$ins_id");210 $filename =~ s|/|:|g; 211 my $uri = URI::file->new("$vol_path/$filename.$ins_id"); 212 212 $log->debug("generated uri $uri"); 213 213 214 214 # TODO add some stuff here to retry if unsucessful 215 215 eval { 216 _create_empty_file($uri->file );216 _create_empty_file($uri->file, $key); 217 217 }; 218 218 if ($@) { … … 361 361 } 362 362 363 my $uri = URI::file->new("$vol_path/$key.$ins_id"); 363 my $filename = $key; 364 # mange '/'s into ':' 365 $filename =~ s|/|:|g; 366 my $uri = URI::file->new("$vol_path/$filename.$ins_id"); 364 367 $log->debug("generated uri $uri"); 365 368 366 369 # TODO add some stuff here to retry if unsucessful 367 370 eval { 368 _create_empty_file($uri->file );371 _create_empty_file($uri->file, $key); 369 372 }; 370 373 if ($@) { -
trunk/Nebulous/lib/Nebulous/Util.pm
r12961 r13269 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Util.pm,v 1. 4 2007-04-23 20:45:08jhoblitt Exp $3 # $Id: Util.pm,v 1.5 2007-05-05 01:41:29 jhoblitt Exp $ 4 4 5 5 package Nebulous::Util; … … 12 12 use base qw( Exporter ); 13 13 14 use File::ExtAttr qw( setfattr ); 14 15 use Log::Log4perl qw( :levels ); 16 use URI::file; 15 17 use URI; 16 use URI::file;17 18 18 19 my @symbols = qw( … … 79 80 } 80 81 81 sub _create_empty_file { 82 my $path = shift; 82 sub _create_empty_file 83 { 84 my ($path, $key) = @_; 83 85 84 86 # perl's open() can't do an O_CREAT | O_EXCL 85 if ( -e $path ) { 86 die "file $path already exists"; 87 } 87 die "file $path already exists" if (-e $path); 88 88 89 89 my $fh; 90 unless ( open( $fh, '>', $path ) ) { 91 die "can not open $path: $!"; 92 } 90 die "can not open $path: $!" 91 unless (open($fh, '>', $path)); 93 92 94 unless ( close( $fh ) ) { 95 die "can not close $path: $!"; 96 } 93 die "can not close $path: $!" 94 unless (close($fh)); 97 95 98 unless ( chmod 0664, $path ) { 99 die "can not chmod $path: $!"; 100 } 96 die "can not chmod $path: $!" 97 unless (chmod 0664, $path); 98 99 die "can not set xattr on $path: $!" 100 unless (setfattr($path, 'nebulous_key', $key)); 101 101 102 102 return $path; -
trunk/Nebulous/t/03_server_create_object.t
r13206 r13269 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 03_server_create_object.t,v 1.1 7 2007-05-04 00:43:44jhoblitt Exp $5 # $Id: 03_server_create_object.t,v 1.18 2007-05-05 01:41:29 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 2 2;10 use Test::More tests => 28; 11 11 12 12 use lib qw( ./t ./lib ); … … 17 17 use Test::URI; 18 18 use URI::Split qw( uri_split ); 19 use File::ExtAttr qw( getfattr ); 19 20 20 21 my $neb = Nebulous::Server->new( … … 33 34 ok(-e $path, "file exists"); 34 35 uri_scheme_ok($uri, 'file'); 36 37 is(getfattr($path, 'nebulous_key'), 'foo', 'nebulous_key xattr'); 35 38 } 36 39 … … 44 47 ok(-e $path, "file exists"); 45 48 uri_scheme_ok($uri, 'file'); 49 50 is(getfattr($path, 'nebulous_key'), '/foo', 'nebulous_key xattr'); 46 51 } 47 52 … … 55 60 ok(-e $path, "file exists"); 56 61 uri_scheme_ok($uri, 'file'); 62 63 is(getfattr($path, 'nebulous_key'), '/foo/', 'nebulous_key xattr'); 57 64 } 58 65 … … 66 73 ok(-e $path, "file exists"); 67 74 uri_scheme_ok($uri, 'file'); 75 76 is(getfattr($path, 'nebulous_key'), 'foo/', 'nebulous_key xattr'); 68 77 } 69 78 … … 77 86 ok(-e $path, "file exists"); 78 87 uri_scheme_ok($uri, 'file'); 88 89 is(getfattr($path, 'nebulous_key'), 'foo/bar', 'nebulous_key xattr'); 79 90 } 80 91 … … 88 99 ok(-e $path, "file exists"); 89 100 uri_scheme_ok($uri, 'file'); 101 102 is(getfattr($path, 'nebulous_key'), '/foo/bar', 'nebulous_key xattr'); 90 103 } 91 104
Note:
See TracChangeset
for help on using the changeset viewer.
