26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/openc3/utilities/target_file.rb', line 26
def self.all(scope, path_matchers)
result = []
modified = []
rubys3_client = Aws::S3::Client.new
token = nil
while true
resp = rubys3_client.list_objects_v2({
bucket: DEFAULT_BUCKET_NAME,
prefix: "#{scope}/targets",
max_keys: 1000,
continuation_token: token
})
resp.contents.each do |object|
split_key = object.key.split('/')
found = false
path_matchers.each do |path|
if split_key.include?(path)
found = true
break
end
end
next unless found
result_no_scope_or_target_folder = split_key[2..-1].join('/')
if object.key.include?("#{scope}/targets_modified")
modified << result_no_scope_or_target_folder
else
result << result_no_scope_or_target_folder
end
end
break unless resp.is_truncated
token = resp.next_continuation_token
end
if ENV['OPENC3_LOCAL_MODE']
local_modified = OpenC3::LocalMode.local_target_files(scope: scope, path_matchers: path_matchers)
local_modified.each do |filename|
modified << filename unless modified.include?(filename)
result << filename unless result.include?(filename)
end
end
result.map! do |file|
if modified.include?(file)
modified.delete(file)
"#{file}*"
else
file
end
end
result.concat(modified)
result.sort
end
|