Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save BanzaiMan/230550 to your computer and use it in GitHub Desktop.

Select an option

Save BanzaiMan/230550 to your computer and use it in GitHub Desktop.
From e1871a7d1f872489dca7c74c42003341dc7588f0 Mon Sep 17 00:00:00 2001
From: Hiro Asari <asari.ruby@gmail.com>
Date: Mon, 9 Nov 2009 10:42:22 -0600
Subject: [PATCH] Catch Zlib::BufError while reading history.
---
lib/plugins/history.rb | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/plugins/history.rb b/lib/plugins/history.rb
index 7a7ed62..dcecbf1 100644
--- a/lib/plugins/history.rb
+++ b/lib/plugins/history.rb
@@ -21,6 +21,15 @@ module Termtter::Client
if File.exist?(filename)
begin
history = Marshal.load Zlib::Inflate.inflate(File.read(filename))
+ rescue Zlib::BufError => e
+ ui = create_highline
+ delete = ui.ask("Unable to read #{filename}. Do you wish to remove it?")
+ if delete =~ /^y/i
+ if File.delete(filename) > 1
+ puts "Removed #{filename}"
+ end
+ end
+ history = nil
end
if history
keys.each do |key|
--
1.6.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment