Commit a4308c53 authored by Travis Miller's avatar Travis Miller

Add project export API entities

parent b2040837
......@@ -1567,6 +1567,21 @@ class Project < ActiveRecord::Base
Dir.glob("#{export_path}/*export.tar.gz").max_by { |f| File.ctime(f) }
end
def export_status
if export_in_progress?
:started
elsif export_project_path
:finished
else
:none
end
end
def export_in_progress?
shared = Gitlab::ImportExport::Shared.new(relative_path: File.join(disk_path, 'work'))
File.directory?(shared.export_path)
end
def remove_exports
return nil unless export_path.present?
......
......@@ -91,6 +91,21 @@ module API
expose :created_at
end
class ProjectExportStatus < ProjectIdentity
include ::API::Helpers::RelatedResourcesHelpers
expose :export_status
expose :_links, if: lambda { |project, options| project.export_status == :finished } do
expose :api_url do |project|
expose_url(api_v4_projects_export_download_path(id: project.id))
end
expose :web_url do |project|
Gitlab::Routing.url_helpers.download_export_project_url(project)
end
end
end
class ProjectImportStatus < ProjectIdentity
expose :import_status
......
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