Skip to content
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
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: ruby

sudo: false

rvm:
- 1.9.3
- 2.1.5
Expand Down
18 changes: 12 additions & 6 deletions bin/casher
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Casher
msg "attempting to download cache archive"
archive_found = false
urls.each do |url|
msg "fetching #{%r(([^/]+?/[^/]+?)(\?.*)?$).match(url)[1]}"
msg "fetching #{cache_archive_name(url)}"

@fetch_tar = File.expand_path('fetch.tgz', @casher_dir) if path_ext(url) == 'tgz'

Expand Down Expand Up @@ -130,18 +130,20 @@ class Casher
return
end

msg "changes detected, packing new archive"

@push_tar = File.expand_path('push.tgz', @casher_dir) if path_ext(url) == 'tgz'

msg "changes detected, packing new archive"

tar(:c, @push_tar, *cached_directories) do
@counter += 1
puts "." if @counter % 5 == 0
sleep 1
end

msg "uploading archive"
unless system "curl -T %p %p -f -v >#{@casher_dir}/push.log 2>#{@casher_dir}/push.err.log" % [@push_tar, url]
msg "uploading #{cache_archive_name(url)}"
if system "curl -T %p %p -f -v >#{@casher_dir}/push.log 2>#{@casher_dir}/push.err.log" % [@push_tar, url]
msg "cache uploaded"
else
msg "failed to upload cache", :red
puts filter_http_params(File.read("#{@casher_dir}/push.err.log")), filter_http_params(File.read("#{@casher_dir}/push.log"))
end
Expand Down Expand Up @@ -201,12 +203,16 @@ class Casher

if !status.success? && flag.to_s != 'x'
msg "FAILED: #{cmd}", :red
puts errors, output
puts errors.split.delete_if {|l| l.start_with? 'PUT'}, output
end

[stdout, errors]
end

def cache_archive_name(url)
%r(([^/]+?\/[^/]+?)(\?.*)?\?).match(url)[1]
end

def path_ext(url)
path = URI.split(url)[5]
path.split('.').last
Expand Down