Sha256: 525a88b362bd1e3f5b9c5788d5625676a8ba972580f6998550fe77f60820fcc9
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
module Snapsync class Cleanup # The underlying timeline policy object that we use to compute which # snapshots to delete and which to keep attr_reader :policy def initialize(policy) @policy = policy end # @param [SyncTarget] target def cleanup(target, dry_run: false) snapshots = target.each_snapshot.to_a filtered_snapshots = policy.filter_snapshots(snapshots).to_set if filtered_snapshots.any? { |s| s.synchronization_point? } raise InvalidPolicy, "#{policy} returned a snapsync synchronization point in its results" end if filtered_snapshots.empty? raise InvalidPolicy, "#{policy} returned no snapshots" end last_sync_point = snapshots. sort_by(&:num).reverse. find { |s| s.synchronization_point_for?(target) } filtered_snapshots << last_sync_point filtered_snapshots = filtered_snapshots.to_set deleted_snapshots = snapshots.sort_by(&:num).find_all do |s| if !filtered_snapshots.include?(s) target.delete(s, dry_run: dry_run) true end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
snapsync-0.5.0 | lib/snapsync/cleanup.rb |
snapsync-0.4.2 | lib/snapsync/cleanup.rb |
snapsync-0.4.1 | lib/snapsync/cleanup.rb |
snapsync-0.4.0 | lib/snapsync/cleanup.rb |