project export archiver

This commit is contained in:
James Lopez 2016-06-14 22:11:21 +02:00
parent dee6fba5c9
commit 36ccaca35a
4 changed files with 22 additions and 3 deletions

View file

@ -266,8 +266,6 @@ class ProjectsController < Projects::ApplicationController
end
def export_project_path
# TODO: move this, probably to ImportExport and refactor
folder = File.join(Settings.shared['path'], 'tmp/project_exports', @project.path_with_namespace)
Dir.glob("#{folder}/*export.tar.gz").max_by {|f| File.ctime(f)}
Dir.glob("#{@project.export_path}/*export.tar.gz").max_by {|f| File.ctime(f)}
end
end

View file

@ -348,6 +348,11 @@ class Project < ActiveRecord::Base
joins(join_body).reorder('join_note_counts.amount DESC')
end
# Deletes gitlab project export files older than 24 hours
def archive_gitlab_exports!
Gitlab::Popen.popen(%W(find #{export_path} -not -path #{export_path} -mmin +1440 -delete))
end
end
def team
@ -1104,4 +1109,8 @@ class Project < ActiveRecord::Base
Rails.logger.error "Export job failed to start for project ID #{self.id}"
end
end
def export_path
File.join(ImportExport.storage_path, path_with_namespace)
end
end

View file

@ -0,0 +1,9 @@
class GitlabProjectArchiveWorker
include Sidekiq::Worker
sidekiq_options queue: :default
def perform
Project.archive_gitlab_exports!
end
end

View file

@ -288,6 +288,9 @@ Settings.cron_jobs['admin_email_worker']['job_class'] = 'AdminEmailWorker'
Settings.cron_jobs['repository_archive_cache_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['repository_archive_cache_worker']['cron'] ||= '0 * * * *'
Settings.cron_jobs['repository_archive_cache_worker']['job_class'] = 'RepositoryArchiveCacheWorker'
Settings.cron_jobs['gitlab_project_archive_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['gitlab_project_archive_worker']['cron'] ||= '0 * * * *'
Settings.cron_jobs['gitlab_project_archive_worker']['job_class'] = 'GitlabProjectArchiveWorker'
#
# GitLab Shell