diff options
author | James Lopez <james@jameslopez.es> | 2016-04-14 16:57:25 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-04-14 16:57:25 +0200 |
commit | 0852f539aa389c66ef377b7d567c931f928e147f (patch) | |
tree | 82797f5e855f9235d445c943af7161b4cc7d2238 /lib/gitlab/import_export/saver.rb | |
parent | 91ffd8028977984d3ea9a741a3a655ff6dae76b2 (diff) | |
download | gitlab-ce-0852f539aa389c66ef377b7d567c931f928e147f.tar.gz |
refactored stuff, added a save and compress all class and moved mostly everything to lib
Diffstat (limited to 'lib/gitlab/import_export/saver.rb')
-rw-r--r-- | lib/gitlab/import_export/saver.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/saver.rb b/lib/gitlab/import_export/saver.rb new file mode 100644 index 00000000000..f26804d2402 --- /dev/null +++ b/lib/gitlab/import_export/saver.rb @@ -0,0 +1,38 @@ +module Gitlab + module ImportExport + class Saver + include Gitlab::ImportExport::CommandLineUtil + + def self.save(*args) + new(*args).save + end + + def initialize(storage_path:) + @storage_path = storage_path + end + + def save + if compress_and_save + remove_storage_path + archive_file + else + false + end + end + + private + + def compress_and_save + tar_czf(archive: archive_file, dir: @storage_path) + end + + def remove_storage_path + FileUtils.rm_rf(@storage_path) + end + + def archive_file + @archive_file ||= File.join(@storage_path, '..', 'project.tar.gz') + end + end + end +end |