From 810ca5968754b0778c679a5b21f626189a1f1135 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Tue, 19 Sep 2023 11:29:52 -0400 Subject: [PATCH] short circuit this glob if youve already upgraded (#3047) Short circuit this glob if you've already upgraded to 3.0. --- .../initializers/{upgrade_to_2.1.rb => upgrade_to_3.0.rb} | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename apps/dashboard/config/initializers/{upgrade_to_2.1.rb => upgrade_to_3.0.rb} (82%) diff --git a/apps/dashboard/config/initializers/upgrade_to_2.1.rb b/apps/dashboard/config/initializers/upgrade_to_3.0.rb similarity index 82% rename from apps/dashboard/config/initializers/upgrade_to_2.1.rb rename to apps/dashboard/config/initializers/upgrade_to_3.0.rb index 214ab2dd3f..eec51b08e0 100644 --- a/apps/dashboard/config/initializers/upgrade_to_2.1.rb +++ b/apps/dashboard/config/initializers/upgrade_to_3.0.rb @@ -2,11 +2,14 @@ Rails.application.config.after_initialize do # Since https://github.com/OSC/ondemand/pull/1526 all the batch connect cache files - # have moved. So, when folks upgrade to 2.1, let's sync these old files so that + # have moved. So, when folks upgrade to 3.0, let's sync these old files so that # they don't lose their cached choices. old_context_files = "#{Configuration.dataroot}/batch_connect/**/*/context.json" cache_root = BatchConnect::Session.cache_root + # kick out if you've already done this + next if Dir.glob("#{cache_root}/*.json").size.positive? + Dir.glob(old_context_files).map do |old_file| new_filename = old_file.gsub(%r{.*/batch_connect/}, '').gsub('/context.json', '').gsub('/', '_') new_filename = "#{new_filename}.json"