Class: Gitlab::ImportExport::DecompressedArchiveSizeValidator

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/import_export/decompressed_archive_size_validator.rb

Constant Summary collapse

DEFAULT_MAX_BYTES =
10.gigabytes.freeze
CHUNK_SIZE =
4096.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(archive_path:, max_bytes: self.class.max_bytes) ⇒ DecompressedArchiveSizeValidator

Returns a new instance of DecompressedArchiveSizeValidator.


15
16
17
18
19
20
21
22
# File 'lib/gitlab/import_export/decompressed_archive_size_validator.rb', line 15

def initialize(archive_path:, max_bytes: self.class.max_bytes)
  @archive_path = archive_path
  @max_bytes = max_bytes
  @bytes_read = 0
  @total_reads = 0
  @denominator = 5
  @error = nil
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error


13
14
15
# File 'lib/gitlab/import_export/decompressed_archive_size_validator.rb', line 13

def error
  @error
end

Class Method Details

.max_bytesObject


30
31
32
# File 'lib/gitlab/import_export/decompressed_archive_size_validator.rb', line 30

def self.max_bytes
  DEFAULT_MAX_BYTES
end

Instance Method Details

#archive_fileObject


34
35
36
# File 'lib/gitlab/import_export/decompressed_archive_size_validator.rb', line 34

def archive_file
  @archive_file ||= File.open(@archive_path)
end

#valid?Boolean

Returns:

  • (Boolean)

24
25
26
27
28
# File 'lib/gitlab/import_export/decompressed_archive_size_validator.rb', line 24

def valid?
  strong_memoize(:valid) do
    validate
  end
end