commit 493dec4380a629988443ee34ff564ca258a808de
parent 3a26ba66430b01d2f7a0436ad1a8240082e15d62
Author: Damien Leone <damien.leone@fensalir.fr>
Date: Fri, 9 Jul 2010 13:00:13 +0200
Check that a message has a location before trying to sync it
Diffstat:
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -630,7 +630,9 @@ EOS
end
def sync_message m, overwrite
- m.sync_back if $config[:sync_back_to_maildir] and m.source.is_a? Maildir
+ ## TODO: we should not save the message if the sync_back failed
+ ## since it would overwrite the location field
+ m.sync_back
doc = synchronize { find_doc(m.id) }
existed = doc != nil
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
@@ -286,7 +286,13 @@ EOS
end
def sync_back
- location.sync_back @labels
+ begin
+ location.sync_back @labels if $config[:sync_back_to_maildir] and source.is_a? Maildir
+ true
+ rescue SourceError => e
+ warn "cannot sync back #{id}, locations have been removed from the disk"
+ false
+ end
end
## returns all the content from a message that will be indexed