diff options
author | Nick Thomas <nick@gitlab.com> | 2018-01-23 19:03:02 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-02-05 10:38:57 +0000 |
commit | 30a43b7e04b98616f379bdd800532c3354df8b19 (patch) | |
tree | 62711e0084cf584b350469e41f5a02e5654de427 /app/models/project.rb | |
parent | f5990e444a98dc259e2af8c373910cd9ec15b0bd (diff) | |
download | gitlab-ce-30a43b7e04b98616f379bdd800532c3354df8b19.tar.gz |
Fix export removal for hashed-storage projects within a renamed or deleted namespace
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 03c5475c31f..12d5f28f5ea 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -69,6 +69,7 @@ class Project < ActiveRecord::Base before_destroy :remove_private_deploy_keys after_destroy -> { run_after_commit { remove_pages } } + after_destroy :remove_exports after_validation :check_pending_delete @@ -1525,6 +1526,8 @@ class Project < ActiveRecord::Base end def export_path + return nil unless namespace.present? || hashed_storage?(:repository) + File.join(Gitlab::ImportExport.storage_path, disk_path) end @@ -1533,8 +1536,9 @@ class Project < ActiveRecord::Base end def remove_exports - _, status = Gitlab::Popen.popen(%W(find #{export_path} -not -path #{export_path} -delete)) - status.zero? + return nil unless export_path.present? + + FileUtils.rm_rf(export_path) end def full_path_slug |