s3sync-cf 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/s3sync +90 -86
- metadata +3 -19
data/bin/s3sync
CHANGED
@@ -416,102 +416,106 @@ ENDUSAGE
|
|
416
416
|
end
|
417
417
|
|
418
418
|
if $S3syncOptions['--cf-invalidate'] && $S3syncOptions['--cf-dist-id']
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
419
|
+
puts "Invalidating following assets from s3 - #{filesToInvalidateOnCloudfront.inspect}" if $S3syncOptions['--verbose']
|
420
|
+
unless false && $S3syncOptions['--dryrun']
|
421
|
+
begin
|
422
|
+
acf = RightAws::AcfInterface.new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY)
|
423
|
+
invalidate_resp = acf.create_invalidation($S3syncOptions['--cf-dist-id'], :path => filesToInvalidateOnCloudfront)
|
424
|
+
puts invalidate_resp.inspect
|
425
|
+
rescue Exception => xcp
|
426
|
+
puts xcp.message
|
427
|
+
end
|
428
|
+
end
|
425
429
|
end
|
426
430
|
end #main
|
427
431
|
|
428
432
|
|
429
433
|
# ---------- NODE ---------- #
|
430
434
|
class Node
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
435
|
+
attr_reader :name
|
436
|
+
attr_reader :size
|
437
|
+
attr_reader :tag
|
438
|
+
attr_reader :date
|
439
|
+
def initialize(name='', size = 0, tag = '', date = Time.now.utc)
|
440
|
+
@name = name
|
441
|
+
@size = size
|
442
|
+
@tag = tag
|
443
|
+
@date = date
|
444
|
+
end
|
445
|
+
def directory?()
|
446
|
+
@tag == $S3syncDirTag and @size == $S3syncDirString.length
|
447
|
+
end
|
444
448
|
end
|
445
449
|
|
446
450
|
# ---------- S3Node ---------- #
|
447
451
|
class S3Node < Node
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
452
|
+
@path = nil
|
453
|
+
@bucket = nil
|
454
|
+
@result = nil
|
455
|
+
def initialize(bucket, prefix, itemOrName)
|
456
|
+
@bucket = bucket
|
457
|
+
if itemOrName.kind_of? String
|
458
|
+
@name = itemOrName
|
459
|
+
@name.sub!(%r{/$}, "") # don't create directories with a slash on the end
|
460
|
+
#6/2007. the prefix can be filled but the name empty, in the case of s3sync -r somedir somebucket:
|
461
|
+
if (not prefix.empty? and @name.empty?)
|
462
|
+
@name = prefix
|
463
|
+
itemOrName = prefix
|
464
|
+
prefix = ""
|
465
|
+
end
|
466
|
+
slash = prefix.empty? ? "" : "/"
|
467
|
+
@path = prefix + slash + itemOrName
|
468
|
+
else
|
469
|
+
@name = (itemOrName.name.slice((prefix.length)..itemOrName.name.length) or '')
|
470
|
+
# depending whether the prefix is / tailed, the name might need trimming
|
471
|
+
@name.sub!(%r{^/},"") # get rid of leading slash in name if there (from above simplistic split)
|
472
|
+
@name.sub!(%r{/$}, "") # don't create directories with a slash on the end
|
473
|
+
@path = itemOrName.name
|
474
|
+
@path.sub!(%r{/$}, "") # don't create directories with a slash on the end
|
475
|
+
@size = itemOrName.size
|
476
|
+
@tag = itemOrName.tag.gsub(/"/,'')
|
477
|
+
@date = Time.xmlschema(itemOrName.date)
|
478
|
+
end
|
479
|
+
debug("s3 node object init. Name:#{@name} Path:#{@path} Size:#{@size} Tag:#{@tag} Date:#{@date}")
|
480
|
+
end
|
481
|
+
# get this item from s3 into the provided stream
|
482
|
+
# S3 pushes to the local item, due to how http streaming is implemented
|
483
|
+
def to_stream(s)
|
484
|
+
@result = S3sync.S3try(:get_stream, @bucket, @path, {}, s)
|
485
|
+
end
|
486
|
+
def symlink?()
|
487
|
+
unless @result
|
488
|
+
@result = S3sync.S3try(:head, @bucket, @path)
|
489
|
+
end
|
490
|
+
debug("symlink value is: #{@result.object.metadata['symlink']}")
|
491
|
+
@result.object.metadata['symlink'] == 'true'
|
492
|
+
end
|
493
|
+
def owner
|
494
|
+
unless @result
|
495
|
+
@result = S3sync.S3try(:head, @bucket, @path)
|
496
|
+
end
|
497
|
+
debug("Owner of this s3 node is #{@result.object.metadata['owner']}")
|
498
|
+
@result.object.metadata['owner'].to_i # if not there, will be nil => 0 which == root so good default
|
499
|
+
end
|
500
|
+
def group
|
501
|
+
unless @result
|
502
|
+
@result = S3sync.S3try(:head, @bucket, @path)
|
503
|
+
end
|
504
|
+
@result.object.metadata['group'].to_i # 0 default ok
|
505
|
+
end
|
506
|
+
def permissions
|
507
|
+
g = @result.object.metadata['permissions']
|
508
|
+
g ? g.to_i : 600 # default to owner only
|
509
|
+
end
|
510
|
+
def updateFrom(fromNode)
|
511
|
+
if fromNode.respond_to?(:stream)
|
512
|
+
meta = Hash.new
|
513
|
+
meta['owner'] = fromNode.owner.to_s
|
514
|
+
meta['group'] = fromNode.group.to_s
|
515
|
+
meta['permissions'] = fromNode.permissions.to_s
|
516
|
+
meta['symlink'] = 'true' if fromNode.symlink?
|
517
|
+
begin
|
518
|
+
theStream = fromNode.stream
|
515
519
|
theStream = ProgressStream.new(theStream, fromNode.size) if $S3syncOptions['--progress']
|
516
520
|
|
517
521
|
s3o = S3::S3Object.new(theStream, meta)
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3sync-cf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
version: 0.0.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- arvindj
|
@@ -26,11 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ~>
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 11
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 1
|
33
|
-
- 0
|
34
24
|
version: 2.1.0
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
@@ -81,23 +71,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
71
|
requirements:
|
82
72
|
- - ">="
|
83
73
|
- !ruby/object:Gem::Version
|
84
|
-
hash: 3
|
85
|
-
segments:
|
86
|
-
- 0
|
87
74
|
version: "0"
|
88
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
76
|
none: false
|
90
77
|
requirements:
|
91
78
|
- - ">="
|
92
79
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 3
|
94
|
-
segments:
|
95
|
-
- 0
|
96
80
|
version: "0"
|
97
81
|
requirements: []
|
98
82
|
|
99
83
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.5.0
|
101
85
|
signing_key:
|
102
86
|
specification_version: 3
|
103
87
|
summary: Fork of s3sync to add cloudfront invalidation
|