You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sam Ruby <ru...@apache.org> on 2015/12/14 15:34:54 UTC

[whimsy.git] [1/1] Commit ba492ca: add support for parsing specific mailboxes

Commit ba492ca9477429c0862448a24608533e8b925df6:
    add support for parsing specific mailboxes


Branch: refs/heads/secmail
Author: Sam Ruby <ru...@intertwingly.net>
Committer: Sam Ruby <ru...@intertwingly.net>
Pusher: rubys <ru...@apache.org>

------------------------------------------------------------
www/secmail/parsemail.rb                                     | +++++++++++ ---
------------------------------------------------------------
14 changes: 11 additions, 3 deletions.
------------------------------------------------------------


diff --git a/www/secmail/parsemail.rb b/www/secmail/parsemail.rb
index 952da00..fd529ce 100644
--- a/www/secmail/parsemail.rb
+++ b/www/secmail/parsemail.rb
@@ -20,9 +20,16 @@
 Dir.chdir File.dirname(File.expand_path(__FILE__))
 
 if ARGV.include? '--fetch1'
-  month = Time.now.strftime('%Y%m')
+  ARGV.unshift Time.now.strftime('%Y%m')
+end
+
+if ARGV.any? {|arg| arg =~ /^\d{6}$/}
   Dir.mkdir ARCHIVE unless Dir.exist? ARCHIVE
-  system "rsync -av --no-motd #{SOURCE}/#{month} #{ARCHIVE}/"
+  ARGV.each do |arg|
+    if arg =~ /^\d{6}$/
+      system "rsync -av --no-motd #{SOURCE}/#{arg}* #{ARCHIVE}/"
+    end
+  end
 elsif ARGV.include? '--fetch' or not Dir.exist? database
   system "rsync -av --no-motd --delete --exclude='*.yml' #{SOURCE}/ #{ARCHIVE}/"
 end
@@ -32,7 +39,8 @@
 Dir[File.join(database, '2*')].sort.each do |name|
   # skip YAML files, update output showing latest file being processed
   next if name.end_with? '.yml'
-  next if ARGV.include? '--fetch1'  and not name.include? "/#{month}"
+  next if ARGV.any? {|arg| arg =~ /^\d{6}$/} and
+    not ARGV.any? {|arg| name.include? "/#{arg}"}
   print "#{name.ljust(width)}\r"
   width = name.length