Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --no-meta option to prevent creation of folder files and meta data on S3 #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified s3cmd.rb
100644 → 100755
Empty file.
30 changes: 19 additions & 11 deletions s3sync.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def S3sync.main
[ '--cache-control', GetoptLong::REQUIRED_ARGUMENT ],
[ '--exclude', GetoptLong::REQUIRED_ARGUMENT ],
[ '--make-dirs', GetoptLong::NO_ARGUMENT ],
[ '--no-md5', GetoptLong::NO_ARGUMENT ]
[ '--no-md5', GetoptLong::NO_ARGUMENT ],
[ '--no-meta', GetoptLong::NO_ARGUMENT ]
)

def S3sync.usage(message = nil)
Expand All @@ -80,7 +81,7 @@ def S3sync.usage(message = nil)
--ssl -s --recursive -r --delete
--public-read -p --expires="<exp>" --cache-control="<cc>"
--exclude="<regexp>" --progress --debug -d
--make-dirs --no-md5
--make-dirs --no-md5 --no-meta
One of <source> or <destination> must be of S3 format, the other a local path.
Reminders:
* An S3 formatted item with bucket 'mybucket' and prefix 'mypre' looks like:
Expand Down Expand Up @@ -372,8 +373,11 @@ def S3sync.s3TreeRecurse(g, bucket, prefix, path)
else
LocalNode.new(localPrefix, sourceNode.name)
end
puts "Create node #{sourceNode.name}" if $S3syncOptions['--verbose']
dNode.updateFrom(sourceNode) unless $S3syncOptions['--dryrun']
# Don't upload directory meta files to S3. Requires use of --make-dirs when downloading.
if dNode.kind_of? LocalNode or not $S3syncOptions['--no-meta'] or not sourceNode.directory?
puts "Create node #{sourceNode.name}" if $S3syncOptions['--verbose']
dNode.updateFrom(sourceNode) unless $S3syncOptions['--dryrun']
end
sourceNode = sourceTree.next? ? sourceTree.next : nil
elsif (!sourceNode) or (destinationNode and (sourceNode.name > destinationNode.name))
$stderr.puts "Source does not have #{destinationNode.name}" if $S3syncOptions['--debug']
Expand Down Expand Up @@ -476,24 +480,28 @@ def owner
@result = S3sync.S3try(:head, @bucket, @path)
end
debug("Owner of this s3 node is #{@result.object.metadata['owner']}")
@result.object.metadata['owner'].to_i # if not there, will be nil => 0 which == root so good default
g = @result.object.metadata['owner']
g ? g.to_i : Process.euid # if not there, set to effective user id of this process
end
def group
unless @result
@result = S3sync.S3try(:head, @bucket, @path)
end
@result.object.metadata['group'].to_i # 0 default ok
g = @result.object.metadata['group']
g ? g.to_i : Process.egid # if not there, set to effective group id of this process
end
def permissions
g = @result.object.metadata['permissions']
g ? g.to_i : 600 # default to owner only
g ? g.to_i : 0600 # default to owner only
end
def updateFrom(fromNode)
if fromNode.respond_to?(:stream)
meta = Hash.new
meta['owner'] = fromNode.owner.to_s
meta['group'] = fromNode.group.to_s
meta['permissions'] = fromNode.permissions.to_s
if not $S3syncOptions['--no-meta']
meta['owner'] = fromNode.owner.to_s
meta['group'] = fromNode.group.to_s
meta['permissions'] = fromNode.permissions.to_s
end
meta['symlink'] = 'true' if fromNode.symlink?
begin
theStream = fromNode.stream
Expand Down Expand Up @@ -613,7 +621,7 @@ def group
self.exist? ? self.stat().gid : 0
end
def permissions
self.exist? ? self.stat().mode : 600
self.exist? ? self.stat().mode : 0600
end
def updateFrom(fromNode)
if fromNode.respond_to?(:to_stream)
Expand Down