summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-05-19 13:10:41 +0200
committerJames Lopez <james@jameslopez.es>2016-05-19 13:10:41 +0200
commitbac27df16c35abb2f8115d9c94edcc4ecbace1a7 (patch)
tree12a7febb1630e01c40ab4f703688240f7fd8177c
parentb05b21d2c2525c3e748bd843958a4c42736c1877 (diff)
downloadgitlab-ce-bac27df16c35abb2f8115d9c94edcc4ecbace1a7.tar.gz
Squashed commit of the following:
commit 92de6309e1c918a4ae023641dc42b196b3fb25ea Merge: 6c082ed 30f4dcd Author: James Lopez <james@jameslopez.es> Date: Thu May 19 13:06:34 2016 +0200 Merge branches 'feature/project-export' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-import commit 30f4dcd4c906a71db98833075c76eb59922f5b98 Author: James Lopez <james@jameslopez.es> Date: Thu May 19 13:02:57 2016 +0200 uploads export
-rw-r--r--app/services/projects/import_export/export_service.rb6
-rw-r--r--lib/gitlab/import_export/uploads_saver.rb35
2 files changed, 40 insertions, 1 deletions
diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb
index 0691ca9d468..1a23a4ede97 100644
--- a/app/services/projects/import_export/export_service.rb
+++ b/app/services/projects/import_export/export_service.rb
@@ -4,7 +4,7 @@ module Projects
def execute(options = {})
@shared = Gitlab::ImportExport::Shared.new(relative_path: File.join(project.path_with_namespace, 'work'))
- save_all if [save_version, save_project_tree, bundle_repo, bundle_wiki_repo].all?
+ save_all if [save_version, save_project_tree, save_uploads, bundle_repo, bundle_wiki_repo].all?
cleanup_and_notify_worker if @shared.errors.any?
end
@@ -18,6 +18,10 @@ module Projects
Gitlab::ImportExport::ProjectTreeSaver.new(project: project, shared: @shared).save
end
+ def save_uploads
+ Gitlab::ImportExport::UploadsSaver.save(project: project, shared: @shared)
+ end
+
def bundle_repo
Gitlab::ImportExport::RepoBundler.new(project: project, shared: @shared).bundle
end
diff --git a/lib/gitlab/import_export/uploads_saver.rb b/lib/gitlab/import_export/uploads_saver.rb
new file mode 100644
index 00000000000..3420d2ea4cb
--- /dev/null
+++ b/lib/gitlab/import_export/uploads_saver.rb
@@ -0,0 +1,35 @@
+module Gitlab
+ module ImportExport
+ class UploadsSaver
+
+ def self.save(*args)
+ new(*args).save
+ end
+
+ def initialize(project:, shared:)
+ @project = project
+ @shared = shared
+ end
+
+ def save
+ return true unless File.directory?(uploads_path)
+
+ FileUtils.copy_entry(uploads_path, uploads_export_path)
+ true
+ rescue => e
+ @shared.error(e.message)
+ false
+ end
+
+ private
+
+ def uploads_export_path
+ File.join(@shared.export_path, 'uploads')
+ end
+
+ def uploads_path
+ File.join(Rails.root.join('public/uploads'), project.path_with_namespace)
+ end
+ end
+ end
+end