commit 909626a317d1a0abf3df214663847eb2f2b60a9d
parent a338b34e700416a33d7f9f8aae66a8df5721cf20
Author: Eric Weikl <eric.weikl@gmx.net>
Date: Wed, 30 Oct 2013 20:52:29 +0100
Merge #158: Maildir sync crashes when .sup/sync-back-ok does not exist
Conflicts:
lib/sup.rb
Diffstat:
3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/bin/sup-sync-back-maildir b/bin/sup-sync-back-maildir
@@ -1,4 +1,7 @@
#!/usr/bin/env ruby
+# encoding: utf-8
+
+$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'rubygems'
require 'trollop'
@@ -56,7 +59,8 @@ index.load
$config[:sync_back_to_maildir] = true
begin
- sync_performed = File.readlines Redwood::SYNC_OK_FN
+ sync_performed = []
+ sync_performed = File.readlines(Redwood::SYNC_OK_FN).collect { |e| e.strip }.find_all { |e| not e.empty? } if File.exists? Redwood::SYNC_OK_FN
sources = []
## Try to find out sources given in parameters
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -189,25 +189,32 @@ 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'
- elsif not $config[:sync_back_to_maildir] and File.exists? Redwood::SYNC_OK_FN
- File.delete(Redwood::SYNC_OK_FN)
end
+ elsif not $config[:sync_back_to_maildir] and File.exists? Redwood::SYNC_OK_FN
+ File.delete(Redwood::SYNC_OK_FN)
end
end
def check_syncback_settings
- active_sync_sources = File.readlines(Redwood::SYNC_OK_FN).collect { |s| s.strip }
+ # don't check if syncback was never performed
+ return unless File.exists? Redwood::SYNC_OK_FN
+ active_sync_sources = File.readlines(Redwood::SYNC_OK_FN).collect { |e| e.strip }.find_all { |e| not e.empty? }
return if active_sync_sources.length == 1 and active_sync_sources[0] == Redwood::MAILDIR_SYNC_CHECK_SKIPPED
sources = SourceManager.sources
newly_synced = sources.select { |s| s.is_a? Maildir and s.sync_back_enabled? and not active_sync_sources.include? s.uri }
unless newly_synced.empty?
- Redwood.warn_syncback <<EOS
+
+ details =<<EOS
It appears that the option "sync_back" of the following source(s)
has been changed from false to true since the last execution of
sup:
-#{newly_synced.join("\n")}
EOS
+ newly_synced.each do |s|
+ details += "#{s} (usual: #{s.usual})\n"
+ end
+
+ Redwood.warn_syncback details
end
end
diff --git a/lib/sup/source.rb b/lib/sup/source.rb
@@ -54,7 +54,7 @@ class Source
## Examples for you to look at: mbox.rb and maildir.rb.
bool_accessor :usual, :archived
- attr_reader :uri
+ attr_reader :uri, :usual
attr_accessor :id
def initialize uri, usual=true, archived=false, id=nil