lib/backup/jar.rb in encbs-0.2.1.beta2 vs lib/backup/jar.rb in encbs-0.2.1
- old
+ new
@@ -26,18 +26,18 @@
@last_index = Jar.fetch_index_for(@file_item, @root_path, jar_hash, last_timestamp)
@local_files.keys.each do |file|
current = @local_files[file].dup
current.delete(:timestamp)
-
+
unless @last_index[file].nil?
backup = @last_index[file].dup
backup.delete(:timestamp)
-
+
if (current == backup) or
(!current[:checksum].nil? and current[:checksum] == backup[:checksum])
-
+
@meta_index[file] = @local_files[file]
@meta_index[file][:timestamp] = @last_index[file][:timestamp]
end
end
end
@@ -70,15 +70,13 @@
pbar = ProgressBar.new(
"Copying",
@local_files.keys.count
)
end
-
+
pbar.bar_mark = '*'
- #@local_files = @meta_index.select {|k, v| v[:timestamp] == @timestamp if v.is_a? Hash}
-
begin
@local_files.keys.each do |file|
if @meta_index[file].nil?
unless File.directory? file
data = StringIO.new File.open(file, 'rb').read
@@ -86,19 +84,19 @@
data.seek 0
data = compression.compress(data.read, 3) unless compression.nil?
data = @key.encrypt_to_stream(data) if @key
-
+
@file_item.create_file_once(
"#{jar_data_path}/#{@file_item.file_hash file}",
data
)
-
+
pbar.inc
end
-
+
@meta_index[file] = @local_files[file]
@meta_index[file][:checksum] = checksum
@meta_index[file][:timestamp] = @timestamp
end
end
@@ -108,11 +106,11 @@
:timestamp => @timestamp
})
File.open("/var/tmp/encbs.swap", "w") do |f|
f.puts @meta_index.to_yaml
end
-
+
puts
puts_fail "Index file has been saved that to allow upload into cloud in next run."
else
@file_item.create_file_once(
"#{meta_jar_path}/#{@timestamp}.yml",
@@ -123,10 +121,10 @@
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