Changeset 13269 for trunk/Nebulous/lib
- Timestamp:
- May 4, 2007, 3:41:29 PM (19 years ago)
- Location:
- trunk/Nebulous/lib/Nebulous
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.
