mirror of
https://codeberg.org/h3xx/simplify_static_dir
synced 2024-08-14 23:57:24 +00:00
Use croak/carp instead of die/warn (PBP)
This commit is contained in:
parent
4e2e94881b
commit
3e96b9bc19
3 changed files with 8 additions and 5 deletions
|
@ -2,6 +2,7 @@ package Directory::Simplify::Instruction::Generator;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use overload '""' => 'as_string';
|
use overload '""' => 'as_string';
|
||||||
|
use Carp qw/ carp /;
|
||||||
require File::Compare;
|
require File::Compare;
|
||||||
|
|
||||||
# :squash-remove-start:
|
# :squash-remove-start:
|
||||||
|
@ -126,7 +127,7 @@ sub _entries_contents_match {
|
||||||
|
|
||||||
# warn about hash collision
|
# warn about hash collision
|
||||||
unless ($contents_same) {
|
unless ($contents_same) {
|
||||||
warn "Hash collision between files:\n* $entry_a->{name}\n* $entry_b->{name}\n (don't panic)\n";
|
carp "Hash collision between files:\n* $entry_a->{name}\n* $entry_b->{name}\n (don't panic)\n";
|
||||||
}
|
}
|
||||||
return $contents_same;
|
return $contents_same;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +148,7 @@ sub instructions {
|
||||||
my @non_readonly;
|
my @non_readonly;
|
||||||
foreach my $entry (@{$bucket}) {
|
foreach my $entry (@{$bucket}) {
|
||||||
unless (-w $entry->{dirname}) {
|
unless (-w $entry->{dirname}) {
|
||||||
warn "Warning: $entry->{name} not able to be unlinked!";
|
carp "Warning: $entry->{name} not able to be unlinked!";
|
||||||
}
|
}
|
||||||
push @non_readonly, $entry;
|
push @non_readonly, $entry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package Directory::Simplify::Instruction::Hardlink;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use overload '""' => 'as_string';
|
use overload '""' => 'as_string';
|
||||||
|
use Carp qw/ croak /;
|
||||||
|
|
||||||
# :squash-remove-start:
|
# :squash-remove-start:
|
||||||
require Directory::Simplify::Utils;
|
require Directory::Simplify::Utils;
|
||||||
|
@ -20,10 +21,10 @@ sub run {
|
||||||
# hard link the files
|
# hard link the files
|
||||||
|
|
||||||
unless (unlink $self->{target}->{name}) {
|
unless (unlink $self->{target}->{name}) {
|
||||||
die "Failed to remove file `$self->{target}->{name}': $!\n";
|
croak "Failed to remove file `$self->{target}->{name}': $!\n";
|
||||||
}
|
}
|
||||||
unless (link $self->{source}->{name}, $self->{target}->{name}) {
|
unless (link $self->{source}->{name}, $self->{target}->{name}) {
|
||||||
die "Failed to hard link `$self->{source}->{name}' => `$self->{target}->{name}': $!";
|
croak "Failed to hard link `$self->{source}->{name}' => `$self->{target}->{name}': $!";
|
||||||
}
|
}
|
||||||
# bookkeeping
|
# bookkeeping
|
||||||
++$self->{source}->{nlink};
|
++$self->{source}->{nlink};
|
||||||
|
|
|
@ -3,6 +3,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More 'no_plan';
|
use Test::More 'no_plan';
|
||||||
|
use Carp qw/ croak /;
|
||||||
|
|
||||||
use TestFunctions;
|
use TestFunctions;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ sub put_file {
|
||||||
my $bytes = 1048576; # 1 MB
|
my $bytes = 1048576; # 1 MB
|
||||||
foreach my $file (@files) {
|
foreach my $file (@files) {
|
||||||
open my $fh, '>', $file
|
open my $fh, '>', $file
|
||||||
or die "Failed to open file $file for writing: $!";
|
or croak("Failed to open file $file for writing: $!");
|
||||||
for (my $bytes_written = 0; $bytes_written < $bytes; ++$bytes_written) {
|
for (my $bytes_written = 0; $bytes_written < $bytes; ++$bytes_written) {
|
||||||
print $fh 'A';
|
print $fh 'A';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue