diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-26 12:06:55 +0300 |
---|---|---|
committer | kushalpandya <kushal@gitlab.com> | 2017-06-26 14:16:41 +0300 |
commit | 1180a33571d246d9f2372fef3642ffdd6f5da16b (patch) | |
tree | 4fe26f54af1735892aca72603fc3e699010ce076 | |
parent | 7638e798cfab8427c4129a774fc83b1d2ab2facb (diff) |
Merge branch 'fix-34019' into 'master'
Perform project housekeeping after importing projects
Closes #34019
See merge request !12323
-rw-r--r-- | app/models/project.rb | 17 | ||||
-rw-r--r-- | changelogs/unreleased/fix-34019.yml | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 36ec4f398ca..e1ee22b1a82 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -350,7 +350,10 @@ class Project < ActiveRecord::Base project.run_after_commit { add_import_job } end - after_transition started: :finished, do: :reset_cache_and_import_attrs + after_transition started: :finished do |project, _| + project.reset_cache_and_import_attrs + project.perform_housekeeping + end end class << self @@ -510,6 +513,18 @@ class Project < ActiveRecord::Base remove_import_data end + def perform_housekeeping + return unless repo_exists? + + run_after_commit do + begin + Projects::HousekeepingService.new(self).execute + rescue Projects::HousekeepingService::LeaseTaken => e + Rails.logger.info("Could not perform housekeeping for project #{self.path_with_namespace} (#{self.id}): #{e}") + end + end + end + def remove_import_data import_data&.destroy end diff --git a/changelogs/unreleased/fix-34019.yml b/changelogs/unreleased/fix-34019.yml new file mode 100644 index 00000000000..77ebb18fda6 --- /dev/null +++ b/changelogs/unreleased/fix-34019.yml @@ -0,0 +1,4 @@ +--- +title: Perform project housekeeping after importing projects +merge_request: +author: |