Sha256: caf86d6a87e0d9683f90610be1626b0ae4412f98fcd5fadfe4baa305e7d51218

Contents?: true

Size: 1.05 KB

Versions: 45

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'avm/data/instance/unit'

module Avm
  module Data
    module Instance
      class FilesUnit < ::Avm::Data::Instance::Unit
        EXTENSION = '.tar.gz'

        attr_reader :fs_path_subpath

        def initialize(instance, fs_path_subpath)
          super(instance)
          @fs_path_subpath = fs_path_subpath
        end

        before_load :clear_files

        def files_path
          ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH),
                      fs_path_subpath)
        end

        def dump_command
          instance.host_env.command('tar', '-czf', '-', '-C', files_path, '.')
        end

        def load_command
          instance.host_env.command('tar', '-xzf', '-', '-C', files_path)
        end

        def clear_files
          infom "Removing all files under #{files_path}..."
          instance.host_env.command('mkdir', '-p', files_path).execute!
          instance.host_env.command('find', files_path, '-mindepth', 1, '-delete').execute!
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 2 rubygems

Version Path
eac_tools-0.27.2 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.41.1 lib/avm/data/instance/files_unit.rb
eac_tools-0.27.1 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.41.0 lib/avm/data/instance/files_unit.rb
eac_tools-0.27.0 sub/avm/lib/avm/data/instance/files_unit.rb