diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-02-07 12:01:59 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-02-07 12:01:59 +0000 |
commit | 21e9660dceb98c03920227fa1fbb682cf4769201 (patch) | |
tree | 6408eb0559cd8240839cd4963317b81156a6ce90 /app/models/project.rb | |
parent | fbe48e133803d8654bdddcaf5d96dbf5e39b39bf (diff) | |
parent | 9810dc2e2a607aec81075fbfe60def6257a6d58f (diff) | |
download | gitlab-ce-fe-paginated-environments-pagination.tar.gz |
Merge branch 'fe-paginated-environments-api' into fe-paginated-environments-paginationfe-paginated-environments-pagination
* fe-paginated-environments-api: (304 commits)
added missed commit in rebase
update Grape routes to work with current version of Grape
adds changelog
fixes cursor issue on pipeline pagination
Use random group name to prevent conflicts
List all groups/projects for admins on explore pages
Fix indentation
More backport
Fix filtered search user autocomplete for gitlab instances that are hosted on a subdirectory
Fixed variables_controller_spec.rb test
Backport of the frontend view, including tests
Updated the #create action to render the show view in case of a form error
Improved code styling on the variables_controller_spec
Added tests for the variables controller #update action
Added a variable_controller_spec test to test for flash messages on the #create action
Modified redirection logic in the variables cont.
Added redirections to the index actions for the variables and triggers controllers
Added a flash message to the creation of triggers
Fixed tests, renamed files and methods
Changed the controller/route name to 'ci/cd' and renamed the corresponding files
...
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 0d286bfbaa8..7c5fdad5122 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -53,6 +53,8 @@ class Project < ActiveRecord::Base update_column(:last_activity_at, self.created_at) end + after_destroy :remove_pages + # update visibility_level of forks after_update :update_forks_visibility_level def update_forks_visibility_level @@ -148,6 +150,7 @@ class Project < ActiveRecord::Base has_many :lfs_objects, through: :lfs_objects_projects has_many :project_group_links, dependent: :destroy has_many :invited_groups, through: :project_group_links, source: :group + has_many :pages_domains, dependent: :destroy has_many :todos, dependent: :destroy has_many :notification_settings, dependent: :destroy, as: :source @@ -955,6 +958,7 @@ class Project < ActiveRecord::Base Gitlab::AppLogger.info "Project was renamed: #{old_path_with_namespace} -> #{new_path_with_namespace}" Gitlab::UploadsTransfer.new.rename_project(path_was, path, namespace.path) + Gitlab::PagesTransfer.new.rename_project(path_was, path, namespace.path) end # Expires various caches before a project is renamed. @@ -1156,6 +1160,45 @@ class Project < ActiveRecord::Base ensure_runners_token! end + def pages_deployed? + Dir.exist?(public_pages_path) + end + + def pages_url + # The hostname always needs to be in downcased + # All web servers convert hostname to lowercase + host = "#{namespace.path}.#{Settings.pages.host}".downcase + + # The host in URL always needs to be downcased + url = Gitlab.config.pages.url.sub(/^https?:\/\//) do |prefix| + "#{prefix}#{namespace.path}." + end.downcase + + # If the project path is the same as host, we serve it as group page + return url if host == path + + "#{url}/#{path}" + end + + def pages_path + File.join(Settings.pages.path, path_with_namespace) + end + + def public_pages_path + File.join(pages_path, 'public') + end + + def remove_pages + # 1. We rename pages to temporary directory + # 2. We wait 5 minutes, due to NFS caching + # 3. We asynchronously remove pages with force + temp_path = "#{path}.#{SecureRandom.hex}.deleted" + + if Gitlab::PagesTransfer.new.rename_project(path, temp_path, namespace.path) + PagesWorker.perform_in(5.minutes, :remove, namespace.path, temp_path) + end + end + def wiki @wiki ||= ProjectWiki.new(self, self.owner) end |