Method: OpenC3::TargetFile.all

Defined in:
lib/openc3/utilities/target_file.rb

.all(scope, path_matchers, target: nil) ⇒ Object



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
# File 'lib/openc3/utilities/target_file.rb', line 29

def self.all(scope, path_matchers, target: nil)
  target = target.upcase if target

  include_temp = true
  bucket = Bucket.getClient()
  if target
    prefix = "#{scope}/targets/#{target}/"
    modified_prefix = "#{scope}/targets_modified/#{target}/"
    if target != TEMP_FOLDER
      include_temp = false
    end
  else
    prefix = "#{scope}/targets/"
    modified_prefix = "#{scope}/targets_modified/"
  end
  result, _ = remote_target_files(bucket_client: bucket, prefix: prefix, include_temp: false, path_matchers: path_matchers)
  modified, temp = remote_target_files(bucket_client: bucket, prefix: modified_prefix, include_temp: include_temp, path_matchers: path_matchers)

  # Add in local targets_modified if present
  if ENV['OPENC3_LOCAL_MODE']
    local_modified = OpenC3::LocalMode.local_target_files(scope: scope, target: target, path_matchers: path_matchers, include_temp: include_temp)
    local_modified.each do |filename|
      if include_temp and filename.include?(TEMP_FOLDER)
        temp << filename
      else
        modified << filename unless modified.include?(filename)
        result << filename unless result.include?(filename)
      end
    end
  end

  # Determine if there are any modified files and mark them with '*'
  result.map! do |file|
    if modified.include?(file)
      modified.delete(file)
      "#{file}*"
    else
      file
    end
  end

  # Concat any remaining modified files (new files not in original target)
  result = result.merge(modified)
  result = result.merge(temp.uniq)
  result.sort
end