Add accessor method to packet object for "replace" option
authorJacob Bachmeyer <jcb@gnu.org>
Tue, 27 Jun 2023 01:36:09 +0000 (20:36 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Tue, 27 Jun 2023 01:36:09 +0000 (20:36 -0500)
gatekeeper.pl

index ab485e900e649951010a7bc1564439c37969930e..6b4f862cbfb1eec06f40c6201121afb3436c26b4 100755 (executable)
@@ -1646,6 +1646,7 @@ sub find_package {
   sub file_name_stem { (shift)->{stem} }
 
   sub has_uploaded_file { return 0 }
+  sub allow_overwrite  { return 0 }
 
   sub target_directory;
   sub target_filename;
@@ -1687,8 +1688,9 @@ sub find_package {
     ::validate_directive($self, $self->{oplist});
   }
 
-  sub target_directory { (shift)->{oplist}->[0][1]->{directory} }
-  sub target_filename  { (shift)->{oplist}->[0][1]->{filename}  }
+  sub allow_overwrite  { (shift)->{oplist}->[0][1]->{options}{replace} }
+  sub target_directory { (shift)->{oplist}->[0][1]->{directory} }
+  sub target_filename  { (shift)->{oplist}->[0][1]->{filename}  }
 
   sub target_filepair {
     my $filename = (shift)->target_filename;
@@ -3308,7 +3310,7 @@ foreach my $packet (@packets) {   # each list element is an array reference
          (CONF_DIR_Public, @directory, $install_as.'.sig');
 
        if (-e $final_signature || -e $final_upload) {
-         unless ($op_header->{options}{replace}) {
+         unless ($packet->allow_overwrite) {
            throw processing_error => command => $step,
              summary => $pubfinal." exists and 'replace' was not selected";
          }