Skip to content

Commit

Permalink
short circuit this glob if youve already upgraded (OSC#3047)
Browse files Browse the repository at this point in the history
Short circuit this glob if you've already upgraded to 3.0.
  • Loading branch information
johrstrom authored Sep 19, 2023
1 parent dbe149c commit 810ca59
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 810ca59

Please sign in to comment.