diff options
author | Travis Miller <travis@travismiller.com> | 2018-02-24 23:03:29 -0600 |
---|---|---|
committer | Travis Miller <travis@travismiller.com> | 2018-02-28 20:47:36 -0600 |
commit | a4308c53e5db594a6e351b143e11ceba6033cdc7 (patch) | |
tree | 371771b0a969a0a9501024b2ffa5b090909557fc | |
parent | b20408372b6811520edc3e35702bfe9b053b013b (diff) | |
download | gitlab-ce-a4308c53e5db594a6e351b143e11ceba6033cdc7.tar.gz |
Add project export API entities
-rw-r--r-- | app/models/project.rb | 15 | ||||
-rw-r--r-- | lib/api/entities.rb | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index ba278a49688..791b69bd9ee 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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? diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 167878ba600..f140563882f 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -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 |