Commit 36ccaca3 authored by James Lopez's avatar James Lopez

project export archiver

parent dee6fba5
......@@ -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
......@@ -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
class GitlabProjectArchiveWorker
include Sidekiq::Worker
sidekiq_options queue: :default
def perform
Project.archive_gitlab_exports!
end
end
......@@ -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
......
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