* [sup-devel] [PATCH] Sync and update other threads when Maildir sync-back changes location.
@ 2012-08-21 19:19 Edward Z. Yang
2012-08-21 19:25 ` Edward Z. Yang
0 siblings, 1 reply; 3+ messages in thread
From: Edward Z. Yang @ 2012-08-21 19:19 UTC (permalink / raw)
To: damien.leone; +Cc: sup-devel
From: "Edward Z. Yang" <ezyang@mit.edu>
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
---
lib/sup/maildir.rb | 2 +-
lib/sup/message.rb | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
index 0c8c563..050cfaf 100644
--- a/lib/sup/maildir.rb
+++ b/lib/sup/maildir.rb
@@ -226,7 +226,7 @@ private
new_base = (flags.include?("S")) ? "cur" : "new"
md_base, md_ver, md_flags = maildir_data orig_path
- return orig_path if md_flags == flags
+ return if md_flags == flags
new_loc = File.join new_base, "#{md_base}:#{md_ver},#{flags}"
orig_path = File.join @dir, orig_path
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 0616f75..cd9226e 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -288,7 +288,11 @@ EOS
def sync_back
@locations.each do |l|
if l.valid?
- l.sync_back @labels if $config[:sync_back_to_maildir] and l.source.is_a? Maildir
+ r = l.sync_back @labels if $config[:sync_back_to_maildir] and l.source.is_a? Maildir
+ if r
+ Index.sync_message self, true
+ UpdateManager.relay self, :updated, self
+ end
end
end
end
--
1.7.11.3
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [sup-devel] [PATCH] Sync and update other threads when Maildir sync-back changes location.
2012-08-21 19:19 [sup-devel] [PATCH] Sync and update other threads when Maildir sync-back changes location Edward Z. Yang
@ 2012-08-21 19:25 ` Edward Z. Yang
2012-08-21 19:43 ` Edward Z. Yang
0 siblings, 1 reply; 3+ messages in thread
From: Edward Z. Yang @ 2012-08-21 19:25 UTC (permalink / raw)
To: damien.leone, sup-devel
This fixes the "I changed a message from unread to read in one list (e.g. 'U')
and now when I open the message from inbox it can't find it" bug.
Here is a version that is theoretically more efficient, though God
help you if you have more than one location per message.
commit ca5b02b8ff88412f92984d6b9176ff1876886cc6
Author: Edward Z. Yang <ezyang@mit.edu>
Date: Tue Aug 21 15:19:11 2012 -0400
Sync and update other threads when Maildir sync-back changes location.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
index 0c8c563..050cfaf 100644
--- a/lib/sup/maildir.rb
+++ b/lib/sup/maildir.rb
@@ -226,7 +226,7 @@ private
new_base = (flags.include?("S")) ? "cur" : "new"
md_base, md_ver, md_flags = maildir_data orig_path
- return orig_path if md_flags == flags
+ return if md_flags == flags
new_loc = File.join new_base, "#{md_base}:#{md_ver},#{flags}"
orig_path = File.join @dir, orig_path
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 0616f75..9af847d 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -286,11 +286,16 @@ EOS
end
def sync_back
+ r = nil
@locations.each do |l|
if l.valid?
- l.sync_back @labels if $config[:sync_back_to_maildir] and l.source.is_a? Maildir
+ r ||= l.sync_back @labels if $config[:sync_back_to_maildir] and l.source.is_a? Maildir
end
end
+ if r
+ Index.sync_message self, true
+ UpdateManager.relay self, :updated, self
+ end
end
def merge_labels_from_locations merge_labels
Excerpts from Edward Z. Yang's message of Tue Aug 21 15:19:56 -0400 2012:
> From: "Edward Z. Yang" <ezyang@mit.edu>
>
> Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
> ---
> lib/sup/maildir.rb | 2 +-
> lib/sup/message.rb | 6 +++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
> index 0c8c563..050cfaf 100644
> --- a/lib/sup/maildir.rb
> +++ b/lib/sup/maildir.rb
> @@ -226,7 +226,7 @@ private
> new_base = (flags.include?("S")) ? "cur" : "new"
> md_base, md_ver, md_flags = maildir_data orig_path
>
> - return orig_path if md_flags == flags
> + return if md_flags == flags
>
> new_loc = File.join new_base, "#{md_base}:#{md_ver},#{flags}"
> orig_path = File.join @dir, orig_path
> diff --git a/lib/sup/message.rb b/lib/sup/message.rb
> index 0616f75..cd9226e 100644
> --- a/lib/sup/message.rb
> +++ b/lib/sup/message.rb
> @@ -288,7 +288,11 @@ EOS
> def sync_back
> @locations.each do |l|
> if l.valid?
> - l.sync_back @labels if $config[:sync_back_to_maildir] and l.source.is_a? Maildir
> + r = l.sync_back @labels if $config[:sync_back_to_maildir] and l.source.is_a? Maildir
> + if r
> + Index.sync_message self, true
> + UpdateManager.relay self, :updated, self
> + end
> end
> end
> end
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [sup-devel] [PATCH] Sync and update other threads when Maildir sync-back changes location.
2012-08-21 19:25 ` Edward Z. Yang
@ 2012-08-21 19:43 ` Edward Z. Yang
0 siblings, 0 replies; 3+ messages in thread
From: Edward Z. Yang @ 2012-08-21 19:43 UTC (permalink / raw)
To: damien.leone, sup-devel
Aaand here's an even prettier version.
commit f7d30410d946418a885929f20a498c10e4058243
Author: Edward Z. Yang <ezyang@mit.edu>
Date: Tue Aug 21 15:19:11 2012 -0400
Sync and update other threads when Maildir sync-back changes location.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
index 0c8c563..050cfaf 100644
--- a/lib/sup/maildir.rb
+++ b/lib/sup/maildir.rb
@@ -226,7 +226,7 @@ private
new_base = (flags.include?("S")) ? "cur" : "new"
md_base, md_ver, md_flags = maildir_data orig_path
- return orig_path if md_flags == flags
+ return if md_flags == flags
new_loc = File.join new_base, "#{md_base}:#{md_ver},#{flags}"
orig_path = File.join @dir, orig_path
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 0616f75..3eeea66 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -286,10 +286,11 @@ EOS
end
def sync_back
- @locations.each do |l|
- if l.valid?
- l.sync_back @labels if $config[:sync_back_to_maildir] and l.source.is_a? Maildir
- end
+ if @locations.map { |l|
+ l.sync_back @labels if l.valid? and $config[:sync_back_to_maildir] and l.source.is_a? Maildir
+ }.any?
+ Index.sync_message self, true
+ UpdateManager.relay self, :updated, self
end
end
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-21 19:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21 19:19 [sup-devel] [PATCH] Sync and update other threads when Maildir sync-back changes location Edward Z. Yang
2012-08-21 19:25 ` Edward Z. Yang
2012-08-21 19:43 ` Edward Z. Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox