s.is_a?(Redwood::MBox::Loader) or Trollop::die "#{uri} is not an mbox source."
s
end
- sources = index.usual_sources if sources.empty?
+ sources = index.usual_sources.select { |s| s.is_a? Redwood::MBox::Loader } if sources.empty?
any_modified = false
- sources.each { |s| s.reset! }
sources.each do |source|
$stderr.puts "Scanning #{source}..."
+ source.reset!
num_deleted = num_moved = num_scanned = 0
out_fp = Tempfile.new "sup-sync-back-#{source.id}"
any_modified = true if num_deleted > 0 || num_moved > 0
out_fp.close unless opts[:dry_run]
- unless opts[:dry_run]
+ unless opts[:dry_run] || !any_modified
deleted_fp.flush if deleted_fp
spam_fp.flush if spam_fp
out_fp.close
- FileUtils.mv out_fp.path, URI(source.uri).path
+ FileUtils.mv out_fp.path, source.file_path
end
end
end
end
+ def file_path; URI(uri).path end
+
def self.suggest_labels_for path
## heuristic: use the filename as a label, unless the file
## has a path that probably represents an inbox.
yaml_properties :cur_offset
def initialize cur_offset=0
- filename = Redwood::SENT_FN
- File.open(filename, "w") { } unless File.exists? filename
- super "mbox://" + filename, cur_offset, true, true
+ @filename = Redwood::SENT_FN
+ File.open(@filename, "w") { } unless File.exists? @filename
+ super "mbox://" + @filename, cur_offset, true, true
end
+ def file_path; @filename end
+
def uri; SentManager.source_name; end
def to_s; SentManager.source_name; end
def id; SentManager.source_id; end
@dirty = false
end
+ def file_path; nil end
+
def to_s; @uri.to_s; end
def seek_to! o; self.cur_offset = o; end
def reset!; seek_to! start_offset; end