Skip to content

Commit

Permalink
Make "s3sync sync foo bucket:bar" idempotent
Browse files Browse the repository at this point in the history
Previously, running "s3sync foo bucket:bar" twice in a row, regardless
of whether the contents of "foo" had changed, would result in the second
run uploading and then deleting the same files, leaving you with an empty
S3 bucker:folder.

The other direction, "s3sync sync bucket:bar foo", remains idempotent,
if a little wonky.
  • Loading branch information
spiffxp committed Sep 18, 2014
1 parent 628ac46 commit 01f7681
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Rakefile
@@ -1,3 +1,6 @@
require "bundler/setup"
require "bundler/gem_tasks"
require "bump/tasks"

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
3 changes: 3 additions & 0 deletions lib/s3sync/sync.rb
Expand Up @@ -314,6 +314,9 @@ def read_tree_remote location
def read_trees source, destination
if source.local?
source_tree = LocalDirectory.new(source.path).list_files
source_tree = source_tree.reduce({}) do |a,(_,v)|
key = S3Sync.safe_join([destination.path, v.path]); a[key] = v; a
end
destination_tree = read_tree_remote destination
else
source_tree = read_tree_remote source
Expand Down

0 comments on commit 01f7681

Please sign in to comment.