Skip to content

Commit

Permalink
Merge pull request #5958 from dodona-edu/fix/report-repo-error
Browse files Browse the repository at this point in the history
Add update_activity errors to aggregated errors for mailing
  • Loading branch information
jorg-vr authored Nov 25, 2024
2 parents 3557d0f + e4773af commit 5cd4418
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def process_activities
dirs = activity_dirs
errors = []

# Read all config files and dirconfig files in the activity directories
# filter out the invalid ones and keep track of them to make a single error report at the end
activity_dirs_and_configs = dirs.map do |d|
Pathname.new('./').join(activity_relative_path(d)).parent.descend.each do |p|
read_config_file(full_path.join(p, Activity::DIRCONFIG_FILE))
Expand All @@ -146,14 +148,23 @@ def process_activities
nil
end.compact

# Read the outermost dirconfig file
# if it contains errors, don't process any activities
begin
read_config_file(full_path.join(Activity::DIRCONFIG_FILE))
rescue ConfigParseError => e
errors.push e
activity_dirs_and_configs = []
end

existing_activities = activity_dirs_and_configs
.reject { |_, c| c['internals'].nil? || c['internals']['token'].nil? }
.map { |d, c| [d, Activity.find_by(repository_token: c['internals']['token'], repository_id: id)] }
# rubocop:disable Style/CollectionCompact
# This is a false positive for Hash#compact, where this is Array#compact
.reject { |_, e| e.nil? }
.reject { |_, a| a.nil? }
# rubocop:enable Style/CollectionCompact
.group_by { |_, e| e }
.group_by { |_, a| a }
.transform_values { |l| l.pluck(0) }
handled_directories = []
handled_activity_ids = []
Expand Down

0 comments on commit 5cd4418

Please sign in to comment.