]> git.cworth.org Git - sup/blobdiff - lib/sup.rb
better broken source error message, and fixed compose from thread-view-mode bug
[sup] / lib / sup.rb
index abb5269da4b728e606a73ce9103dab7ad75f0ec4..cf46b8de7b1153f79d36acc7ce14c998e1bebbe5 100644 (file)
@@ -13,13 +13,13 @@ class Object
 end
 
 module Redwood
-  VERSION = "0.0.5"
+  VERSION = "0.0.7"
 
   BASE_DIR   = ENV["SUP_BASE"] || File.join(ENV["HOME"], ".sup")
   CONFIG_FN  = File.join(BASE_DIR, "config.yaml")
   SOURCE_FN  = File.join(BASE_DIR, "sources.yaml")
   LABEL_FN   = File.join(BASE_DIR, "labels.txt")
-  PERSON_FN   = File.join(BASE_DIR, "people.txt")
+  PERSON_FN  = File.join(BASE_DIR, "people.txt")
   CONTACT_FN = File.join(BASE_DIR, "contacts.txt")
   DRAFT_DIR  = File.join(BASE_DIR, "drafts")
   SENT_FN    = File.join(BASE_DIR, "sent.mbox")
@@ -34,6 +34,10 @@ module Redwood
       begin
         yield
       rescue Exception => e
+        File.open("sup-exception-log.txt", "w") do |f|
+          f.puts "--- #{e.class.name} at #{Time.now}"
+          f.puts e.message, e.backtrace
+        end
         $exception ||= e
         raise
       end
@@ -91,7 +95,28 @@ module Redwood
     Redwood::PersonManager.save
   end
 
-  module_function :register_yaml, :save_yaml_obj, :load_yaml_obj, :start, :finish
+  ## not really a good place for this, so I'll just dump it here.
+  def report_broken_sources
+    return unless BufferManager.instantiated?
+    broken_sources = Index.usual_sources.select { |s| s.broken? }
+    unless broken_sources.empty?
+      BufferManager.spawn "Out-of-sync soure notification", TextMode.new(<<EOM)
+Out-of-sync source notification
+-------------------------------
+
+Hi there. It looks like one or more sources have fallen out of sync
+with my index. This can happen when you modify these sources with
+other email clients. (Sorry, I don't play well with others.)
+
+Until this is corrected, messages from these sources cannot be viewed,
+and new messages will not be detected. Luckily, this is easy to correct!
+
+#{broken_sources.map { |s| "Source: " + s.to_s + "\n Error: " + s.broken_msg.wrap(70).join("\n        ") }.join('\n\n')}
+EOM
+    end
+  end
+
+  module_function :register_yaml, :save_yaml_obj, :load_yaml_obj, :start, :finish, :report_broken_sources
 end
 
 ## set up default configuration file
@@ -123,6 +148,7 @@ require "sup/update"
 require "sup/message"
 require "sup/source"
 require "sup/mbox"
+require "sup/maildir"
 require "sup/imap"
 require "sup/person"
 require "sup/account"