From 38f54fc9d21b8de6dc71737e3bfae933f3ae4ee2 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 19 Sep 2008 00:02:40 +0200 Subject: [PATCH] Ask before re-encrypting if nothing changed. Make the default to abort if decrypting was weird --- pws | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pws b/pws index a4a947a..a2c8c40 100755 --- a/pws +++ b/pws @@ -315,7 +315,7 @@ class EncryptedFile def decrypt (outtxt, stderrtxt, statustxt, exitstatus) = GnuPG.gpgcall(@encrypted_content, %w{--decrypt}) if !@new and exitstatus != 0 - proceed = read_input("Warning: gpg returned non-zero exit status #{exitstatus} when decrypting #{@filename}. Proceed?") + proceed = read_input("Warning: gpg returned non-zero exit status #{exitstatus} when decrypting #{@filename}. Proceed?", false) exit(0) unless proceed elsif !@new and outtxt.length == 0 proceed = read_input("Warning: #{@filename} decrypted to an empty file. Proceed?") @@ -460,6 +460,7 @@ class Ed end content = encrypted_file.decrypt + original_content = content while true oldsize = content.length tempfile = Tempfile.open('pws') @@ -488,6 +489,11 @@ class Ed exit(0) unless proceed end + if (original_content == content) + proceed = read_input("Nothing changed. Re-encrypt anyway?", false) + exit(0) unless proceed + end + success = encrypted_file.write_back(content) break if success end -- 2.39.5