Sha256: 07effc7d86ed349b6a58eab7e2ea427e0ae63efbb70d381b6cc86db6e9240122

Contents?: true

Size: 954 Bytes

Versions: 6

Compression:

Stored size: 954 Bytes

Contents

module Proxy::OpenSCAP
  module StorageFsCommon
    include ::Proxy::Log

    private

    def create_directory
      begin
        FileUtils.mkdir_p @path
      rescue StandardError => e
        logger.error "Could not create '#{@path}' directory: #{e.message}"
        raise e
      end
      @path
    end

    def move(source, error_type)
      begin
        create_directory
        FileUtils.mv source, @path
      rescue StandardError => e
        raise error_type, "Could not move file: #{e.message}"
      end
    end

    def store(data, error_type)
      begin
        create_directory
      rescue StandardError => e
        raise error_type, "Could not fulfill request: #{e.message}"
      end

      begin
        target_path = store_file(@path, data)
      rescue StandardError => e
        raise error_type, "Could not store file: #{e.message}"
      end

      logger.debug "File #{target_path} stored in reports dir."
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smart_proxy_openscap-0.12.0 lib/smart_proxy_openscap/storage_fs_common.rb
smart_proxy_openscap-0.11.1 lib/smart_proxy_openscap/storage_fs_common.rb
smart_proxy_openscap-0.11.0 lib/smart_proxy_openscap/storage_fs_common.rb
smart_proxy_openscap-0.9.2 lib/smart_proxy_openscap/storage_fs_common.rb
smart_proxy_openscap-0.9.1 lib/smart_proxy_openscap/storage_fs_common.rb
smart_proxy_openscap-0.9.0 lib/smart_proxy_openscap/storage_fs_common.rb