Skip to content

Commit

Permalink
Merge commit 'refs/pull/124/head' of https://github.com/wtsi-npg/perl…
Browse files Browse the repository at this point in the history
…-irods-wrap into devel

Conflicts:
	lib/WTSI/NPG/iRODS.pm
  • Loading branch information
dkj committed Jun 13, 2017
2 parents 466d368 + 9ec914c commit 2be0248
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions lib/WTSI/NPG/iRODS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2425,20 +2425,23 @@ sub _stage_object {
try {
$self->debug("Staging '$file' to '$staging_path'");
$self->baton_client->put_object($file, $staging_path, @arguments);
# Tag staging file for easy location with a query
$self->add_object_avu($staging_path, $STAGING, 1);
} catch {
$num_errors++;
my @stack = split /\n/msx; # Chop up the stack trace
$stage_error = pop @stack;
} finally {
my @stack1 = split /\n/msx; # Chop up the stack trace
$stage_error = pop @stack1;

try {
# A failed iput may still leave orphaned replicates
if ($self->is_object($staging_path)) {
# Tag staging file for easy location with a query
$self->add_object_avu($staging_path, $STAGING, 1);
$self->debug("Cleaning up (deleting) staging file '$staging_path'");
$self->remove_object($staging_path);
}
} catch {
my @stack = split /\n/msx;
$self->error("Failed to tag staging path '$staging_path': ", pop @stack);
my @stack2 = split /\n/msx;
$self->error("Failed to remove failed staging file '$staging_path': ",
pop @stack2);
};
};

Expand Down Expand Up @@ -2474,8 +2477,13 @@ sub _unstage_object {
# This includes target=1 so we are accepting a race condition
# between customer queries and the file move below
foreach my $avu (@target_meta) {
$self->add_object_avu($staging_path, $avu->{attribute},
$avu->{value}, $avu->{units});
if ($avu->{attribute} eq $STAGING) {
$self->warn("Found $STAGING AVU on published file '$target'");
}
else {
$self->add_object_avu($staging_path, $avu->{attribute},
$avu->{value}, $avu->{units});
}
}
$self->remove_object($target);
}
Expand All @@ -2487,8 +2495,17 @@ sub _unstage_object {
$self->remove_object_avu($target, $STAGING, 1);
} catch {
$num_errors++;
my @stack = split /\n/msx;
$self->error("Failed to move '$staging_path' to '$target': ", pop @stack);
my @stack1 = split /\n/msx;
$unstage_error = pop @stack1;

try {
$self->debug("Cleaning up (deleting) staging file '$staging_path'");
$self->remove_object($staging_path);
} catch {
my @stack2 = split /\n/msx;
$self->error("Failed to remove failed staging file '$staging_path': ",
pop @stack2);
};
};

if ($num_errors > 0) {
Expand Down

0 comments on commit 2be0248

Please sign in to comment.