summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-05-19 13:02:57 +0200
committerJames Lopez <james@jameslopez.es>2016-05-19 13:02:57 +0200
commit30f4dcd4c906a71db98833075c76eb59922f5b98 (patch)
treea8857ede8b45c87e62c33f9305f8ce67012a7111 /lib
parenta5f04ad48849b94aabeeb7450c6059e76372855c (diff)
downloadgitlab-ce-30f4dcd4c906a71db98833075c76eb59922f5b98.tar.gz
uploads export
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/import_export/uploads_saver.rb35
1 files changed, 35 insertions, 0 deletions
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