Really, unlink is destructive, don't do it by default!

This commit is contained in:
Bradley M. Kuhn 2022-12-01 18:01:42 -08:00
parent 101baf1938
commit 872e29b9bc

View file

@ -13,6 +13,7 @@ if (@ARGV < 2) {
my($TYPE, $MAILDIR_FOLDER) = ($ARGV[0], $ARGV[1]); my($TYPE, $MAILDIR_FOLDER) = ($ARGV[0], $ARGV[1]);
die "Bad type, $TYPE" unless $TYPE =~ /^(unlink|svn|print)$/;
my (@dupFolders) = @ARGV[2..$#ARGV]; my (@dupFolders) = @ARGV[2..$#ARGV];
my %msgs; # indexed by Message-Id my %msgs; # indexed by Message-Id
@ -101,10 +102,12 @@ foreach my $dir (@msgDirs) {
system("svn rm \"$existing_file\""); system("svn rm \"$existing_file\"");
die "Unable to unlink file $existing_file: $!" die "Unable to unlink file $existing_file: $!"
unless $? == 0; unless $? == 0;
} else { } elsif ($TYPE eq 'unlink') {
print STDERR "Removing $existing_file\n"; print STDERR "Removing $existing_file\n";
die "Unable to unlink $existing_file: $!" die "Unable to unlink $existing_file: $!"
unless unlink($existing_file) == 1; unless unlink($existing_file) == 1;
} else {
die "doing nothing here, type operation not known: $TYPE";
} }
} else { } else {
$msgs{$id} = $fields; $msgs{$id} = $fields;