Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mirroring fixes.

  • Loading branch information...
commit 72205755aae8c174de6d25a9a3cebea28ca1c085 1 parent f7bfba8
Pat Allan pat authored
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/backup/syncer/cloud.rb
16 lib/backup/syncer/cloud.rb
View
@@ -108,14 +108,22 @@ def local_hashes
end
def remote_files
- @remote_files ||= bucket.files.select { |file|
- file.key[/^#{path}\/#{directory.split('/').first}\//]
+ @remote_files ||= bucket.files.to_a.select { |file|
+ file.key[%r{^#{remote_base}/}]
}.inject({}) { |hash, file|
- hash[file.key.gsub(/^#{path}\//, '')] = file
+ key = file.key.gsub(/^#{remote_base}\//,
+ "#{directory.split('/').last}/")
+ hash[key] = file
hash
}
end
+ def remote_base
+ @remote_base ||= [path, directory.split('/').last].select { |part|
+ part && part.strip.length > 0
+ }.join('/')
+ end
+
def sync_file(relative_path, mirror)
local_file = local_files[relative_path]
remote_file = remote_files[relative_path]
@@ -125,7 +133,7 @@ def sync_file(relative_path, mirror)
:key => "#{path}/#{relative_path}".gsub(/^\//, ''),
:body => File.open(local_file.path)
) unless remote_file && remote_file.etag == local_file.md5
- elsif mirror
+ elsif remote_file && mirror
remote_file.destroy
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.