lib/backup/jar.rb in encbs-0.2.1.alpha vs lib/backup/jar.rb in encbs-0.2.1.beta1
- old
+ new
@@ -10,11 +10,11 @@
def jar_hash
Digest::MD5.hexdigest(@local_path)
end
- def save increment = false, compression = nil
+ def save increment = false, compression = nil, purge = false
@meta_index = {}
@local_files = hash_local_files
if increment
last_timestamp = Jar.jar_versions(@file_item, @root_path, jar_hash, true).last
@@ -116,12 +116,23 @@
else
@file_item.create_file_once(
"#{meta_jar_path}/#{@timestamp}.yml",
@meta_index.to_yaml
)
- end
- pbar.finish
+ pbar.finish
+
+ if purge
+ puts "Removing previous backups..."
+ previous_versions = Jar.jar_versions @file_item, @root_path, jar_hash, true
+ previous_versions.delete @timestamp
+
+ previous_versions.each do |version|
+ @file_item.delete_file "#{meta_jar_path}/#{version}.yml"
+ @file_item.delete_dir "#{@root_path}/#{jar_hash}/#{version}"
+ end
+ end
+ end
end
def hash_local_files
files = {}