Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
* [sup-devel] [PATCH 1/4] factor saving out of thread/message classes
@ 2009-12-30  1:38 Rich Lane
  2009-12-30  1:38 ` [sup-devel] [PATCH 2/4] async thread indexing Rich Lane
  2009-12-31 20:09 ` [sup-devel] [PATCH 1/4] factor saving out of thread/message classes William Morgan
  0 siblings, 2 replies; 5+ messages in thread
From: Rich Lane @ 2009-12-30  1:38 UTC (permalink / raw)
  To: sup-devel

---
 lib/sup/index.rb                   |    7 +++++++
 lib/sup/message.rb                 |    5 +----
 lib/sup/modes/thread-index-mode.rb |    2 +-
 lib/sup/thread.rb                  |    2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index ff03f19..5d8d714 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -172,6 +172,13 @@ class BaseIndex
   def parse_query s
     unimplemented
   end
+
+  def save_thread t
+    t.each_dirty_message do |m|
+      update_message_state m 
+      m.clear_dirty
+    end
+  end
 end
 
 index_name = ENV['SUP_INDEX'] || $config[:index] || DEFAULT_INDEX
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index f3ac874..76ce330 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -182,11 +182,8 @@ class Message
   ## don't tempt me.
   def sanitize_message_id mid; mid.gsub(/(\s|[^\000-\177])+/, "")[0..254] end
 
-  def save_state index
-    return unless @dirty
-    index.update_message_state self
+  def clear_dirty
     @dirty = false
-    true
   end
 
   def has_label? t; @labels.member? t; end
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
index 82f258b..c4a7d38 100644
--- a/lib/sup/modes/thread-index-mode.rb
+++ b/lib/sup/modes/thread-index-mode.rb
@@ -477,7 +477,7 @@ EOS
       BufferManager.say("Saving threads...") do |say_id|
         dirty_threads.each_with_index do |t, i|
           BufferManager.say "Saving modified thread #{i + 1} of #{dirty_threads.length}...", say_id
-          t.save_state Index
+          Index.save_thread t
         end
       end
     end
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
index 2300305..3fdf1f6 100644
--- a/lib/sup/thread.rb
+++ b/lib/sup/thread.rb
@@ -112,7 +112,7 @@ class Thread
 
   def set_labels l; each { |m, *o| m && m.labels = l }; end
   def has_label? t; any? { |m, *o| m && m.has_label?(t) }; end
-  def save_state index; each { |m, *o| m && m.save_state(index) }; end
+  def each_dirty_message; each { |m, *o| m && m.dirty? && yield(m) }; end
 
   def direct_participants
     map { |m, *o| [m.from] + m.to if m }.flatten.compact.uniq
-- 
1.6.3.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-12-31 20:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-30  1:38 [sup-devel] [PATCH 1/4] factor saving out of thread/message classes Rich Lane
2009-12-30  1:38 ` [sup-devel] [PATCH 2/4] async thread indexing Rich Lane
2009-12-30  1:38   ` [sup-devel] [PATCH 3/4] immediate " Rich Lane
2009-12-30  1:38     ` [sup-devel] [PATCH 4/4] force the index sync thread to give up the cpu Rich Lane
2009-12-31 20:09 ` [sup-devel] [PATCH 1/4] factor saving out of thread/message classes William Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox