Skip to content

Commit

Permalink
Do error handling for copying or symlinking file.
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Jun 3, 2014
1 parent 97ae564 commit 12f66d6
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions lib/App/Sqitch/Engine/oracle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,33 @@ sub _file_for_script {
# Alias or copy the file to a temporary directory that's removed on exit.
(my $alias = $file->basename) =~ s/[@?%\$]/_/g;
$alias = $self->tmpdir->file($alias);

# Remove existing file.
if (-e $alias) {
$alias->remove or hurl oracle => __x(
'Cannot remove {file}: {error}',
file => $alias,
error => $!
);
}

if ($^O eq 'MSWin32') {
# Copy the file.
$file->copy_to($alias);
# Copy it.
$file->copy_to($alias) or hurl oracle => __x(
'Cannot copy {file} to {alias}: {error}',
file => $file,
alias => $alias,
error => $!
);
} else {
# Symlink!
unlink $alias;
symlink $file, $alias;
# Symlink it.
$alias->remove;
symlink $file, $alias or hurl oracle => __x(
'Cannot symlink {file} to {alias}: {error}',
file => $file,
alias => $alias,
error => $!
);
}

# Return the alias.
Expand Down

0 comments on commit 12f66d6

Please sign in to comment.