Sha256: 7dc20b0f9d9d29b82d4d9a20967abc6e09a4b2342744220ecf93a29dd9e12ff6
Contents?: true
Size: 1.01 KB
Versions: 17
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'fileutils' require_relative '../../bolt/error' module Bolt class ProjectManager class Migrator def initialize(outputter) @outputter = outputter end protected def backup_file(origin_path, backup_dir) unless File.exist?(origin_path) @outputter.print_action_step( "Could not find file #{origin_path}, skipping backup." ) return end date = Time.new.strftime("%Y%m%d_%H%M%S%L") FileUtils.mkdir_p(backup_dir) filename = File.basename(origin_path) backup_path = File.join(backup_dir, "#{filename}.#{date}.bak") @outputter.print_action_step( "Backing up #{filename} from #{origin_path} to #{backup_path}" ) begin FileUtils.cp(origin_path, backup_path) rescue StandardError => e raise Bolt::FileError.new("#{e.message}; unable to create backup of #{filename}.", origin_path) end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems