Sha256: affe7fe1870cce1fbb5d1d7503f4229bbc341fe4e50598ce5865684ee968d75e

Contents?: true

Size: 564 Bytes

Versions: 3

Compression:

Stored size: 564 Bytes

Contents

# frozen_string_literal: true

require 'dry/transaction/operation'
require 'pg_export/import'

class PgExport
  module Operations
    class RemoveOldDumpsFromFtp
      include Dry::Transaction::Operation
      include Import['repositories.ftp_dump_repository', 'config']

      def call(dump:, ftp_adapter:)
        dumps = ftp_adapter.list(dump.database + '_*').drop(config.keep_dumps)
        dumps.each do |filename|
          ftp_adapter.delete(filename)
        end

        Success(removed_dumps: dumps, ftp_adapter: ftp_adapter)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_export-0.7.2 lib/pg_export/lib/pg_export/operations/remove_old_dumps_from_ftp.rb
pg_export-0.7.1 lib/pg_export/lib/pg_export/operations/remove_old_dumps_from_ftp.rb
pg_export-0.7.0 lib/pg_export/lib/pg_export/operations/remove_old_dumps_from_ftp.rb