From 872e29b9bc9344d3f65b828163bd4e0fe53e5e75 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Thu, 1 Dec 2022 18:01:42 -0800 Subject: [PATCH] Really, unlink is destructive, don't do it by default! --- remove-dup-mails-from-maildir.plx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/remove-dup-mails-from-maildir.plx b/remove-dup-mails-from-maildir.plx index 3974795..4c77029 100755 --- a/remove-dup-mails-from-maildir.plx +++ b/remove-dup-mails-from-maildir.plx @@ -13,6 +13,7 @@ if (@ARGV < 2) { my($TYPE, $MAILDIR_FOLDER) = ($ARGV[0], $ARGV[1]); +die "Bad type, $TYPE" unless $TYPE =~ /^(unlink|svn|print)$/; my (@dupFolders) = @ARGV[2..$#ARGV]; my %msgs; # indexed by Message-Id @@ -101,10 +102,12 @@ foreach my $dir (@msgDirs) { system("svn rm \"$existing_file\""); die "Unable to unlink file $existing_file: $!" unless $? == 0; - } else { + } elsif ($TYPE eq 'unlink') { print STDERR "Removing $existing_file\n"; die "Unable to unlink $existing_file: $!" unless unlink($existing_file) == 1; + } else { + die "doing nothing here, type operation not known: $TYPE"; } } else { $msgs{$id} = $fields;