lib/io_streams/pgp/writer.rb in iostreams-0.10.0 vs lib/io_streams/pgp/writer.rb in iostreams-0.10.1
- old
+ new
@@ -37,11 +37,11 @@
# Default: true
#
# compression: [:none|:zip|:zlib|:bzip2]
# Note: Standard PGP only supports :zip.
# :zlib is better than zip.
- # :bzip2 is best, but uses a lot of memory.
+ # :bzip2 is best, but uses a lot of memory and is much slower.
# Default: :zip
#
# compress_level: [Integer]
# Compression level
# Default: 6
@@ -62,10 +62,10 @@
stdin.binmode if binary
yield(stdin)
stdin.close
rescue Errno::EPIPE
# Ignore broken pipe because gpg terminates early due to an error
- ::File.delete(file_name_or_io)
+ ::File.delete(file_name_or_io) if ::File.exist?(file_name_or_io)
raise(Pgp::Failure, "GPG Failed writing to encrypted file: #{file_name_or_io}: #{out.read.chomp}")
end
unless waith_thr.value.success?
::File.delete(file_name_or_io) if ::File.exist?(file_name_or_io)
raise(Pgp::Failure, "GPG Failed to create encrypted file: #{file_name_or_io}: #{out.read.chomp}")