Class: Gitlab::GithubImport::AttachmentsDownloader
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::AttachmentsDownloader
- Includes:
- BulkImports::FileDownloads::FilenameFetch, BulkImports::FileDownloads::Validations, ImportExport::CommandLineUtil
- Defined in:
- lib/gitlab/github_import/attachments_downloader.rb
Constant Summary collapse
- DownloadError =
Class.new(StandardError)
- UnsupportedAttachmentError =
Class.new(StandardError)
- FILENAME_SIZE_LIMIT =
chars before the extension
255
- DEFAULT_FILE_SIZE_LIMIT =
Gitlab::CurrentSettings..megabytes
- TMP_DIR =
File.join(Dir.tmpdir, 'github_attachments').freeze
Constants included from BulkImports::FileDownloads::FilenameFetch
BulkImports::FileDownloads::FilenameFetch::REMOTE_FILENAME_PATTERN
Constants included from ImportExport::CommandLineUtil
ImportExport::CommandLineUtil::CLEAN_DIR_IGNORE_FILE_NAMES, ImportExport::CommandLineUtil::CommandLineUtilError, ImportExport::CommandLineUtil::DEFAULT_DIR_MODE, ImportExport::CommandLineUtil::FileOversizedError, ImportExport::CommandLineUtil::HardLinkError, ImportExport::CommandLineUtil::UNTAR_MASK
Instance Attribute Summary collapse
-
#file_size_limit ⇒ Object
readonly
Returns the value of attribute file_size_limit.
-
#file_url ⇒ Object
readonly
Returns the value of attribute file_url.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(file_url, options: {}, file_size_limit: DEFAULT_FILE_SIZE_LIMIT) ⇒ AttachmentsDownloader
constructor
A new instance of AttachmentsDownloader.
- #perform ⇒ Object
Methods included from BulkImports::FileDownloads::Validations
Methods included from ImportExport::CommandLineUtil
#gunzip, #gzip, #gzip_with_options, #mkdir_p, #tar_cf, #tar_czf, #untar_xf, #untar_zxf
Constructor Details
#initialize(file_url, options: {}, file_size_limit: DEFAULT_FILE_SIZE_LIMIT) ⇒ AttachmentsDownloader
Returns a new instance of AttachmentsDownloader.
19 20 21 22 23 24 25 26 |
# File 'lib/gitlab/github_import/attachments_downloader.rb', line 19 def initialize(file_url, options: {}, file_size_limit: DEFAULT_FILE_SIZE_LIMIT) @file_url = file_url @options = @file_size_limit = file_size_limit filename = URI(file_url).path.split('/').last @filename = ensure_filename_size(filename) end |
Instance Attribute Details
#file_size_limit ⇒ Object (readonly)
Returns the value of attribute file_size_limit.
17 18 19 |
# File 'lib/gitlab/github_import/attachments_downloader.rb', line 17 def file_size_limit @file_size_limit end |
#file_url ⇒ Object (readonly)
Returns the value of attribute file_url.
17 18 19 |
# File 'lib/gitlab/github_import/attachments_downloader.rb', line 17 def file_url @file_url end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
17 18 19 |
# File 'lib/gitlab/github_import/attachments_downloader.rb', line 17 def filename @filename end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/gitlab/github_import/attachments_downloader.rb', line 17 def @options end |
Instance Method Details
#delete ⇒ Object
38 39 40 |
# File 'lib/gitlab/github_import/attachments_downloader.rb', line 38 def delete FileUtils.rm_rf File.dirname(filepath) end |
#perform ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/gitlab/github_import/attachments_downloader.rb', line 28 def perform validate_filepath download_url = get_assets_download_redirection_url file = download_from(download_url) validate_symlink file end |