## uri_or_fp is horrific. need to refactor.
def initialize uri_or_fp, start_offset=nil, usual=true, archived=false, id=nil, labels=[]
@mutex = Mutex.new
- @labels = (labels || []).freeze
+ @labels = ((labels || []) - LabelManager::RESERVED_LABELS).uniq.freeze
case uri_or_fp
when String
- uri_or_fp = Source.expand_filesystem_uri uri_or_fp
- uri = URI(uri_or_fp)
+ uri = URI(Source.expand_filesystem_uri(uri_or_fp))
raise ArgumentError, "not an mbox uri" unless uri.scheme == "mbox"
raise ArgumentError, "mbox uri ('#{uri}') cannot have a host: #{uri.host}" if uri.host
@f = File.open uri.path
+ @path = uri.path
else
@f = uri_or_fp
+ @path = uri_or_fp.path
end
super uri_or_fp, start_offset, usual, archived, id
end
- def file_path; URI(uri).path end
- def is_source_for? uri; super || (URI(Source.expand_filesystem_uri(uri)) == URI(self.uri)); end
+ def file_path; @path end
+ def is_source_for? uri; super || (self.uri.is_a?(String) && (URI(Source.expand_filesystem_uri(uri)) == URI(Source.expand_filesystem_uri(self.uri)))) end
def self.suggest_labels_for path
## heuristic: use the filename as a label, unless the file
ret
end
- def raw_full_message offset
+ def raw_message offset
ret = ""
- each_raw_full_message_line(offset) { |l| ret += l }
+ each_raw_message_line(offset) { |l| ret += l }
ret
end
## apparently it's a million times faster to call this directly if
## we're just moving messages around on disk, than reading things
- ## into memory with raw_full_message.
+ ## into memory with raw_message.
##
## i hoped never to have to move shit around on disk but
## sup-sync-back has to do it.
- def each_raw_full_message_line offset
+ def each_raw_message_line offset
@mutex.synchronize do
@f.seek offset
yield @f.gets
end
self.cur_offset = next_offset
- [returned_offset, @labels]
+ [returned_offset, (@labels + [:unread]).uniq]
end
end