Last active
August 29, 2015 14:14
-
-
Save ejuher/3f4c637b419020081404 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| schema_path = [0, 1, 2].map do |n| | |
| File.join("prod-backup", "schemas", (Time.current - n.days).strftime("%Y_%m_%d")) | |
| end.select do |filepath| | |
| File.exist? File.join(File::SEPARATOR, "Volumes", filepath) | |
| end.first || "file not found" | |
| # changed to: | |
| n = 0; schema_path = "file not found"; | |
| while n < 3 && schema_path == "file not found" do | |
| filepath = File.join("prod-backup", "schemas", (Time.current - n.days).strftime("%Y_%m_%d")) | |
| schema_path = filepath if File.exist? File.join(File::SEPARATOR, "Volumes", filepath) | |
| n += 1 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment