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
avm-0.56.1 lib/avm/data/instance/files_unit.rb
eac_tools-0.45.2 sub/avm/lib/avm/data/instance/files_unit.rb
eac_tools-0.45.1 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.56.0 lib/avm/data/instance/files_unit.rb
eac_tools-0.45.0 sub/avm/lib/avm/data/instance/files_unit.rb
eac_tools-0.44.0 sub/avm/lib/avm/data/instance/files_unit.rb
eac_tools-0.43.0 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.55.0 lib/avm/data/instance/files_unit.rb
eac_tools-0.42.0 sub/avm/lib/avm/data/instance/files_unit.rb
eac_tools-0.41.0 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.54.0 lib/avm/data/instance/files_unit.rb
eac_tools-0.40.0 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.53.0 lib/avm/data/instance/files_unit.rb
eac_tools-0.39.0 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.52.0 lib/avm/data/instance/files_unit.rb
eac_tools-0.38.0 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.51.0 lib/avm/data/instance/files_unit.rb
eac_tools-0.37.2 sub/avm/lib/avm/data/instance/files_unit.rb
avm-0.50.0 lib/avm/data/instance/files_unit.rb
eac_tools-0.37.1 sub/avm/lib/avm/data/instance/files_unit.rb