Method: Redwood.start

Defined in:
lib/sup.rb

.start(bypass_sync_check = false) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/sup.rb', line 162

def start bypass_sync_check = false
  managers.each { |x| fail "#{x} already instantiated" if x.instantiated? }

  FileUtils.mkdir_p Redwood::BASE_DIR
  $config = load_config Redwood::CONFIG_FN
  @log_io = File.open(Redwood::LOG_FN, 'a')
  Redwood::Logger.add_sink @log_io
  Redwood::HookManager.init Redwood::HOOK_DIR
  Redwood::SentManager.init $config[:sent_source] || 'sup://sent'
  Redwood::ContactManager.init Redwood::CONTACT_FN
  Redwood::LabelManager.init Redwood::LABEL_FN
  Redwood::AccountManager.init $config[:accounts]
  Redwood::DraftManager.init Redwood::DRAFT_DIR
  Redwood::SearchManager.init Redwood::SEARCH_FN

  managers.each { |x| x.init unless x.instantiated? }

  return if bypass_sync_check

  if $config[:sync_back_to_maildir]
    if not File.exists? Redwood::SYNC_OK_FN
      Redwood.warn_syncback <<EOS
It appears that the "sync_back_to_maildir" option has been changed
from false to true since the last execution of sup.
EOS
      $stderr.puts <<EOS

Should I complain about this again? (Y/n)
EOS
      File.open(Redwood::SYNC_OK_FN, 'w') {|f| f.write(Redwood::MAILDIR_SYNC_CHECK_SKIPPED) } if STDIN.gets.chomp.downcase == 'n'
    end
  elsif not $config[:sync_back_to_maildir] and File.exists? Redwood::SYNC_OK_FN
    File.delete(Redwood::SYNC_OK_FN)
  end
end