]> err.no Git - pwstore/commitdiff
Ask before re-encrypting if nothing changed. Make the default to abort if decrypting...
authorPeter Palfrader <peter@palfrader.org>
Thu, 18 Sep 2008 22:02:40 +0000 (00:02 +0200)
committerPeter Palfrader <peter@palfrader.org>
Thu, 18 Sep 2008 22:02:40 +0000 (00:02 +0200)
pws

diff --git a/pws b/pws
index a4a947ae108a3edd907c916c7aa23310cf304593..a2c8c406351c10e581389158212dffc5f6b18edf 100755 (executable)
--- 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