de-archived messages should be auto-added to inbox
maildir
undo
+remove stupid percent_done source methods
future
------
def uri; DraftManager.source_name; end
def each
- ids = Dir.entries(@dir).select { |x| x =~ /^\d+$/ }.map { |x| x.to_i }.sort
+ ids = get_ids
ids.each do |id|
- if id > cur_offset
+ if id >= cur_offset
self.cur_offset = id
yield [id, [:draft, :inbox]]
end
end
def start_offset; 0; end
- def end_offset; Dir.new(@dir).entries.sort.last.to_i; end
+ def end_offset
+ ids = get_ids
+ ids.empty? ? 0 : (ids.last + 1)
+ end
+
+private
+
+ def get_ids
+ Dir.entries(@dir).select { |x| x =~ /^\d+$/ }.map { |x| x.to_i }.sort
+ end
end
Redwood::register_yaml(DraftLoader, %w(cur_offset))
def select t=nil
t ||= @threads[curpos]
+ ## this isn't working entirely. TODO:figure out why
t = t.clone # required so that messages added later on don't completely
# screw everything up
def load_n_threads n=LOAD_MORE_THREAD_NUM, opts={}
@mbid = BufferManager.say "Searching for threads..."
orig_size = @ts.size
- last_update = Time.now
+ last_update = Time.now - 9999 # oh yeah
@ts.load_n_threads(@ts.size + n, opts) do |i|
BufferManager.say "Loaded #{i} threads...", @mbid
if (Time.now - last_update) >= 0.25
@mutex.synchronize do
found = {}
Index.usual_sources.each do |source|
+# yield "source #{source} is done? #{source.done?} (cur_offset #{source.cur_offset} >= #{source.end_offset})"
yield "Loading from #{source}... " unless source.done? || source.broken?
num = 0
numi = 0
## To write a new source, subclass this class, and implement:
##
## - start_offset
- ## - end_offset
+ ## - end_offset (exclusive!)
## - pct_done (percent of the way cur_offset is to end_offset)
## - load_header offset
## - load_message offset