IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13269 for trunk/Nebulous/lib


Ignore:
Timestamp:
May 4, 2007, 3:41:29 PM (19 years ago)
Author:
jhoblitt
Message:

add File::ExtAttr support

Location:
trunk/Nebulous/lib/Nebulous
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/lib/Nebulous/Server.pm

    r13251 r13269  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.38 2007-05-04 23:36:46 jhoblitt Exp $
     3# $Id: Server.pm,v 1.39 2007-05-05 01:41:29 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    208208    my $filename = $key;
    209209    # 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");
    212212    $log->debug("generated uri $uri");
    213213
    214214    # TODO add some stuff here to retry if unsucessful
    215215    eval {
    216         _create_empty_file($uri->file);
     216        _create_empty_file($uri->file, $key);
    217217    };
    218218    if ($@) {
     
    361361    }
    362362
    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");
    364367    $log->debug("generated uri $uri");
    365368
    366369    # TODO add some stuff here to retry if unsucessful
    367370    eval {
    368         _create_empty_file($uri->file);
     371        _create_empty_file($uri->file, $key);
    369372    };
    370373    if ($@) {
  • trunk/Nebulous/lib/Nebulous/Util.pm

    r12961 r13269  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Util.pm,v 1.4 2007-04-23 20:45:08 jhoblitt Exp $
     3# $Id: Util.pm,v 1.5 2007-05-05 01:41:29 jhoblitt Exp $
    44
    55package Nebulous::Util;
     
    1212use base qw( Exporter );
    1313
     14use File::ExtAttr qw( setfattr );
    1415use Log::Log4perl qw( :levels );
     16use URI::file;
    1517use URI;
    16 use URI::file;
    1718
    1819my @symbols = qw(
     
    7980}
    8081
    81 sub _create_empty_file {
    82     my $path = shift;
     82sub _create_empty_file
     83{
     84    my ($path, $key) = @_;
    8385
    8486    # 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);
    8888
    8989    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));
    9392
    94     unless ( close( $fh ) ) {
    95         die "can not close $path: $!";
    96     }
     93    die "can not close $path: $!"
     94        unless (close($fh));
    9795
    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));
    101101
    102102    return $path;
Note: See TracChangeset for help on using the changeset viewer.