You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2022/05/02 21:19:54 UTC

[whimsy] branch master updated: Prepare for testing as cron jobs

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ca5a3f5 Prepare for testing as cron jobs
2ca5a3f5 is described below

commit 2ca5a3f5c394d45d95951a56de4b1a41ed97c7d6
Author: Sebb <se...@apache.org>
AuthorDate: Mon May 2 22:19:48 2022 +0100

    Prepare for testing as cron jobs
---
 tools/merge_subscriptions.rb | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/tools/merge_subscriptions.rb b/tools/merge_subscriptions.rb
index a7d65cee..ce1c1e65 100644
--- a/tools/merge_subscriptions.rb
+++ b/tools/merge_subscriptions.rb
@@ -56,10 +56,6 @@ def merge_files(old_host, new_host, out)
     f.puts("#{total} total") # add total back in
   end
 
-  # merge qmail.ids
-  merged = File.read(File.join(OLD, 'qmail.ids')).split("\n").union(File.read(File.join(new_host, 'qmail.ids')).split("\n"))
-  File.write(File.join(out, 'qmail.ids'), merged.join("\n"))
-
   # merge list-flags
   flags = {}
   File.open(File.join(old_host, 'list-flags')).each do |line|
@@ -113,10 +109,27 @@ def merge_files(old_host, new_host, out)
   FileUtils.copy_file(File.join(new_host, 'list-start'), File.join(out, 'list-start'), true)
 end
 
-OLD = '/srv/subscriptions1' # old host needs to push files here
-NEW = '/srv/subscriptions2' # new host will push files here
-OUT = '/srv/subscriptions0' # this needs to be changed to '/srv/subscriptions0' when working
+# merge qmail.ids
+def merge_qmail(old_host, new_host, out)
+  merged = File.read(File.join(old_host, 'qmail.ids')).
+    split("\n").union(File.read(File.join(new_host, 'qmail.ids')).split("\n"))
+  File.write(File.join(out, 'qmail.ids'), merged.join("\n"))
+end
+
+OLD = '/srv/subscriptions1' # old host puts files here
+NEW = '/srv/subscriptions2' # new host puts files here
+OUT = '/srv/subscriptions0' # this needs to be changed to '/srv/subscriptions' when working
+
+if __FILE__ == $0
+  type = ARGV.shift
+  if type == 'qmail'
+    merge_qmail OLD, NEW, OUT
+  elsif type == 'files'
+    merge_files OLD, NEW, OUT
+  else
+    raise "Unexpected merge type: expected 'qmail' or 'files'"
+  end
+end
 
-merge_files OLD, NEW, OUT
 
 # TODO: link this into a file update checker