diff options
author | Rémy Coutable <remy@rymai.me> | 2017-04-10 11:23:21 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-10 11:23:21 +0300 |
commit | c98add157732004d9a2eaa39770edf84eaca6896 (patch) | |
tree | 84101fcea712f011ba69f30d53ab0ad9c00fb824 | |
parent | 01adf920c4da977328c38836327681eb4c52cbee (diff) | |
parent | ad27f20426975cf515fd55e4b5b75e5d4703315c (diff) |
Merge branch 'clean_carrierwave_tempfiles' into 'master'
Clean carrierwave tempfiles
Closes #28540
See merge request !9466
-rw-r--r-- | app/uploaders/file_uploader.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/clean_carrierwave_tempfiles.yml | 4 | ||||
-rw-r--r-- | db/post_migrate/20170408033905_remove_old_cache_directories.rb | 23 | ||||
-rw-r--r-- | db/schema.rb | 2 |
4 files changed, 28 insertions, 5 deletions
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index d6ccf0dc92c..d2783ce5b2f 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -38,10 +38,6 @@ class FileUploader < GitlabUploader File.join(dynamic_path_segment, @secret) end - def cache_dir - File.join(base_dir, 'tmp', @project.path_with_namespace, @secret) - end - def model project end diff --git a/changelogs/unreleased/clean_carrierwave_tempfiles.yml b/changelogs/unreleased/clean_carrierwave_tempfiles.yml new file mode 100644 index 00000000000..53fa69700ff --- /dev/null +++ b/changelogs/unreleased/clean_carrierwave_tempfiles.yml @@ -0,0 +1,4 @@ +--- +title: Periodically clean up temporary upload files to recover storage space +merge_request: 9466 +author: blackst0ne diff --git a/db/post_migrate/20170408033905_remove_old_cache_directories.rb b/db/post_migrate/20170408033905_remove_old_cache_directories.rb new file mode 100644 index 00000000000..b23b52896b9 --- /dev/null +++ b/db/post_migrate/20170408033905_remove_old_cache_directories.rb @@ -0,0 +1,23 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +# Remove all files from old custom carrierwave's cache directories. +# See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9466 + +class RemoveOldCacheDirectories < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + # FileUploader cache. + FileUtils.rm_rf(Dir[Rails.root.join('public', 'uploads', 'tmp', '*')]) + end + + def down + # Old cache is not supposed to be recoverable. + # So the down method is empty. + end +end diff --git a/db/schema.rb b/db/schema.rb index d400c823387..3422847d729 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170407140450) do +ActiveRecord::Schema.define(version: 20170408033905) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "pg_trgm" |