From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.58.247.3 with SMTP id ya3csp820774vec; Thu, 23 Aug 2012 07:45:00 -0700 (PDT) Received: by 10.60.13.104 with SMTP id g8mr1240959oec.82.1345733099577; Thu, 23 Aug 2012 07:44:59 -0700 (PDT) Return-Path: Received: from rubyforge.org (50-56-192-79.static.cloud-ips.com. [50.56.192.79]) by mx.google.com with ESMTP id bd6si6875105obb.96.2012.08.23.07.44.58; Thu, 23 Aug 2012 07:44:59 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 50.56.192.79 as permitted sender) client-ip=50.56.192.79; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 50.56.192.79 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id A3FE02E06C; Thu, 23 Aug 2012 14:44:57 +0000 (UTC) Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU [18.9.25.13]) by rubyforge.org (Postfix) with ESMTP id 393962E06A for ; Thu, 23 Aug 2012 14:40:30 +0000 (UTC) X-AuditID: 1209190d-b7fd56d000000933-d2-503640de26d6 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id C3.35.02355.ED046305; Thu, 23 Aug 2012 10:40:30 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q7NEeUvo008060; Thu, 23 Aug 2012 10:40:30 -0400 Received: from localhost ([64.119.153.34]) (authenticated bits=0) (User authenticated as ezyang@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q7NEePo8020358; Thu, 23 Aug 2012 10:40:29 -0400 (EDT) From: "Edward Z. Yang" To: sup-devel , "damien.leone" References: <1345559230-sup-5105@javelin> <1345614331-17294-1-git-send-email-ezyang@mit.edu> <1345614564-sup-5523@javelin> <1345665956-sup-4988@javelin> In-reply-to: <1345665956-sup-4988@javelin> Date: Thu, 23 Aug 2012 10:40:22 -0400 Message-Id: <1345732781-sup-2983@javelin> User-Agent: Sup/git X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMIsWRmVeSWpSXmKPExsUixG6nonvPwSzAYO8+DYtX5/uYLB5P38Pu wOQx7ddKJo99+yYyBzBFcdmkpOZklqUW6dslcGVM2PKaqeC4SsX7r8/ZGxjnSXcxcnJICJhI /Hz5jRnCFpO4cG89WxcjF4eQwD5Gie9/F7FCOBsYJebM72eGcJ4xSjz+3MPUxcjBwSygLrF+ nhBINxuQ+ejYU1YQW0QgWuLR4gao+hmMEhd3PABbwSmgJXHy5SqwImGBUIkD5z6CzWERUJVY OlkcJMwroClx/cUjdhBbVEBY4smRZrBWZgF5ieats5knMPLPQtg8C0lmASPTKkbZlNwq3dzE zJzi1GTd4uTEvLzUIl0jvdzMEr3UlNJNjKCw45Tk3cH47qDSIUYBDkYlHt4X5qYBQqyJZcWV uYcYJTmYlER5de3NAoT4kvJTKjMSizPii0pzUosPMUpwMCuJ8HpxAuV4UxIrq1KL8mFS0hws SuK8V1Ju+gsJpCeWpGanphakFsFkZTg4lCR47e2AGgWLUtNTK9Iyc0oQ0kwcnCDDeYCGRzuA DC8uSMwtzkyHyJ9iVJQS5+UDaRYASWSU5sH1wtLCK0ZxoFeEeblAqniAKQWu+xXQYCagwWpX jUEGlyQipKQaGG8qmonv1Hre96z8YNOJYsnvp5ubuZhuSArY9e7XENm53mP5AYPM5abzkz8d ucN84fMx9vc8P+R7rp4OvrzXwVYm6Lrr6f9TrWuM5t5efnNmQqWZg91Kri1H7ySFC+3/sfrp vc+vOpZIi7OJmty4nvjwktDS3rIdXhOfqlw+bCPa/WbrefUrYd5KLMUZiYZazEXFiQACPmJC 5gIAAA== Subject: Re: [sup-devel] [PATCH] Implement moving message between Maildir sources based on label. X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org It looks like the current patchset will *destroy* all labels you have on messages, so be careful! (This was masked for me since most of my labels are from before-add-message.rb, and that hook gets reapplied) Edward Excerpts from Edward Z. Yang's message of Wed Aug 22 16:09:40 -0400 2012: > Here is an improved version that handles the thread/message distinction > better; previously, if you archived something, it's possible only some of > the messages got moved if you hadn't run sup-sync-back-maildir. > > commit a25c345c15c8859a041cc9dc13090d7b8feb3d58 > Author: Edward Z. Yang > Date: Tue Aug 21 23:40:03 2012 -0400 > > Implement moving message between Maildir sources based on label. > > Signed-off-by: Edward Z. Yang > > diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb > index 95305c2..a7bf567 100644 > --- a/lib/sup/maildir.rb > +++ b/lib/sup/maildir.rb > @@ -76,9 +76,23 @@ class Maildir < Source > with_file_for(id) { |f| RMail::Parser.read f } > end > > + def wrong_source? labels > + new_source = nil > + $config[:maildir_labels].each do |k,v| > + v.each do |lbl,i| > + if lbl.nil? or labels.member? lbl > + new_source = i > + break > + end > + end if v.any? { |lbl,i| i == @id } > + end if $config[:maildir_labels] > + new_source > + end > + > def sync_back id, labels > + new_source = wrong_source? labels || @id > flags = maildir_reconcile_flags id, labels > - maildir_mark_file id, flags > + maildir_move_file id, new_source, flags > end > > def raw_header id > @@ -221,24 +235,31 @@ private > new_flags.to_a.sort.join > end > > - def maildir_mark_file orig_path, flags > + def maildir_move_file orig_path, new_source_id, flags > @mutex.synchronize do > new_base = (flags.include?("S")) ? "cur" : "new" > md_base, md_ver, md_flags = maildir_data orig_path > > - return if md_flags == flags > + return if md_flags == flags and new_source_id == @id > + > + new_source = SourceManager[new_source_id] > > new_loc = File.join new_base, "#{md_base}:#{md_ver},#{flags}" > orig_path = File.join @dir, orig_path > - new_path = File.join @dir, new_loc > + new_path = File.join new_source.file_path, new_loc > tmp_path = File.join @dir, "tmp", "#{md_base}:#{md_ver},#{flags}" > > File.link orig_path, tmp_path > File.unlink orig_path > - File.link tmp_path, new_path > + begin > + File.link tmp_path, new_path > + rescue SystemCallError > + File.unlink new_path # XXX kinda unsafe eh > + File.link tmp_path, new_path > + end > File.unlink tmp_path > > - new_loc > + [new_source, new_loc] > end > end > end > diff --git a/lib/sup/message.rb b/lib/sup/message.rb > index 3eeea66..4139f3e 100644 > --- a/lib/sup/message.rb > +++ b/lib/sup/message.rb > @@ -285,6 +285,10 @@ EOS > location.each_raw_message_line &b > end > > + def wrong_source? > + $config[:sync_back_to_maildir] and @locations.any? { |l| l.valid? and l.source.is_a? Maildir and l.wrong_source? @labels} > + end > + > def sync_back > if @locations.map { |l| > l.sync_back @labels if l.valid? and $config[:sync_back_to_maildir] and l.source.is_a? Maildir > @@ -726,8 +730,17 @@ class Location > end > > def sync_back labels > - new_info = source.sync_back(@info, labels) if source.respond_to? :sync_back > - @info = new_info if new_info > + pair = source.sync_back(@info, labels) if source.respond_to? :sync_back > + if pair > + new_source, new_info = pair > + @source = new_source if new_source > + @info = new_info if new_info > + end > + pair > + end > + > + def wrong_source? labels > + source.wrong_source? labels if source.respond_to? :wrong_source > end > > ## much faster than raw_message > diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb > index b08bae2..c1e4b40 100644 > --- a/lib/sup/thread.rb > +++ b/lib/sup/thread.rb > @@ -113,7 +113,7 @@ class Thread > > def set_labels l; each { |m, *o| m && m.labels = l }; end > def has_label? t; any? { |m, *o| m && m.has_label?(t) }; end > - def each_dirty_message; each { |m, *o| m && m.dirty? && yield(m) }; end > + def each_dirty_message; each { |m, *o| m && (m.dirty? || m.wrong_source?) && yield(m) }; end > > def direct_participants > map { |m, *o| [m.from] + m.to if m }.flatten.compact.uniq _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel