Commit 2c4d6344 authored by Kamil Trzciński's avatar Kamil Trzciński

Do not create keep_arounds when importing

Today, when processing Note/MergeRequestDiff/MergeRequest/DiffNote,
we would create keep arounds in a transactaion when importing.

This does not make sense, as this repository is somehow a replica
of another one and we cannot guarantee anything about this repository,
also this increases the repository fragmentation while creating them.
parent a6dc1781
......@@ -22,7 +22,7 @@ class DiffNote < Note
validate :verify_supported
before_validation :set_line_code, if: :on_text?
after_save :keep_around_commits
after_save :keep_around_commits, unless: :importing?
after_commit :create_diff_file, on: :create
def discussion_class(*)
......@@ -104,7 +104,7 @@ class DiffNote < Note
end
def should_create_diff_file?
on_text? && note_diff_file.nil? && start_of_discussion?
false && on_text? && note_diff_file.nil? && start_of_discussion?
end
def fetch_diff_file
......
......@@ -242,7 +242,7 @@ class MergeRequest < ApplicationRecord
ignore_column :state, remove_with: '12.7', remove_after: '2019-12-22'
after_save :keep_around_commit
after_save :keep_around_commit, unless: :importing?
alias_attribute :project, :target_project
alias_attribute :project_id, :target_project_id
......
......@@ -164,7 +164,7 @@ class MergeRequestDiff < ApplicationRecord
# hooks that run when an attribute was changed are run twice.
reset
keep_around_commits
keep_around_commits unless importing?
end
def set_as_latest_diff
......
......@@ -155,7 +155,7 @@ class Note < ApplicationRecord
after_initialize :ensure_discussion_id
before_validation :nullify_blank_type, :nullify_blank_line_code
before_validation :set_discussion_id, on: :create
after_save :keep_around_commit, if: :for_project_noteable?
after_save :keep_around_commit, if: :for_project_noteable?, unless: :importing?
after_save :expire_etag_cache
after_save :touch_noteable
after_destroy :expire_etag_cache
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment