report refresh_file_list errors
[cloudstore.git] / lib / CloudStore / API.pm
index 6902520..39a27cd 100644 (file)
@@ -36,6 +36,7 @@ sub new {
 sub slice_dir_port {
        my ($self,$slice) = @_;
        my ( undef, $dir, $port, undef ) = getgrnam($slice);
+       die "getgrnam $slice: $!" if $!;
        warn "# slice_dir_port $slice = $dir $port\n";
        return ( $dir, $port );
 }
@@ -77,8 +78,12 @@ sub create_user {
        close($fh);
 
        my $slice = $ENV{SLICE} || 's1';
+       $slice =~ s{/.+/(\w+)$}{$1};
        my ( $dir, $port ) = $self->slice_dir_port( $slice );
 
+       $dir ||= $ENV{SLICE};
+       $port ||= 6501;
+
        if ( ! $found ) {
                $max_uid++;
                $dir .= "/$max_uid";
@@ -101,7 +106,7 @@ sub create_user {
        # FIXME update quota only on create?
        $self->gearman_do( $self->dir2gearman( $dir, 'quota', 'set' ) => "$found $new_quota" );
 
-       return $found;
+       return 'u' . $found;
 }
 
 sub mkbasepath {
@@ -302,7 +307,9 @@ sub refresh_file_list {
        my $full_path = "$user->{dir}/.meta/files";
        if ( -e $full_path ) {
                warn "## refresh_file_list $full_path";
-               unlink $full_path;
+               unlink $full_path || warn "unlink $full_path: $!";
+       } else {
+               warn "## refresh_file_list $full_path missing";
        }
 }