cookbook-omnifetch 0.10.1 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b7baff1c908f3ee02466f86ff7225a6a567006ed325313514d429eb07bddaa
|
4
|
+
data.tar.gz: a30c239d1ff4f032738cf9755226aff95e6f7df330c5119b367fa520306a9372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7f11e46181d038e79d55e527ebc743b977ed012ad0630dbfe8f687bdc36c9638a0a7e70eb24feacc1fc2ef960cdd68f4cdbff55eea8d5bdd98c5f29f2b25962
|
7
|
+
data.tar.gz: 5ad4d570c3fe10fa6f30c055d8bb0d73dd24fc1a90c15fe804007bda3b9738780d0e87128ecfae2cb569e5bdba949ad3d2f3e48999e58c27b99dd970f4cae297
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "threaded_job_queue"
|
2
|
+
require "digest/md5"
|
2
3
|
|
3
4
|
module CookbookOmnifetch
|
4
5
|
|
@@ -27,7 +28,7 @@ module CookbookOmnifetch
|
|
27
28
|
next unless @metadata.key?(type.to_s)
|
28
29
|
|
29
30
|
@metadata[type.to_s].each do |file|
|
30
|
-
yield file["url"], file["path"]
|
31
|
+
yield file["url"], file["path"], file["checksum"]
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -46,50 +47,58 @@ module CookbookOmnifetch
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def install
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
queue = ThreadedJobQueue.new
|
50
|
+
metadata = http_client.get(url_path)
|
51
|
+
clean_cache(metadata)
|
52
|
+
sync_cache(metadata)
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
# Removes files from cache that are not supposed to be there, based on
|
56
|
+
# files in metadata.
|
57
|
+
def clean_cache(metadata)
|
58
|
+
actual_file_list = Dir.glob(File.join(install_path, "**/*"))
|
59
|
+
expected_file_list = []
|
60
|
+
CookbookMetadata.new(metadata).files { |_, path, _| expected_file_list << File.join(install_path, path) }
|
61
|
+
|
62
|
+
extra_files = actual_file_list - expected_file_list
|
63
|
+
extra_files.each do |path|
|
64
|
+
if File.file?(path)
|
65
|
+
FileUtils.rm(path)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
58
69
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
70
|
+
# Downloads any out-of-date files into installer cache, overwriting
|
71
|
+
# those that don't match the checksum provided the metadata @ url_path
|
72
|
+
def sync_cache(metadata)
|
73
|
+
queue = ThreadedJobQueue.new
|
74
|
+
CookbookMetadata.new(metadata).files do |url, path, checksum|
|
75
|
+
dest_path = File.join(install_path, path)
|
76
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
77
|
+
if file_outdated?(dest_path, checksum)
|
78
|
+
queue << lambda do |_lock|
|
79
|
+
http_client.streaming_request(url) do |tempfile|
|
80
|
+
tempfile.close
|
81
|
+
FileUtils.mv(tempfile.path, dest_path)
|
82
|
+
end
|
63
83
|
end
|
64
84
|
end
|
65
85
|
end
|
66
|
-
|
67
86
|
queue.process(CookbookOmnifetch.chef_server_download_concurrency)
|
68
|
-
|
69
|
-
FileUtils.mv(staging_path, install_path)
|
70
87
|
end
|
71
88
|
|
72
|
-
#
|
73
|
-
# better chance of getting an atomic move if your temporary working
|
74
|
-
# directory is on the same device/volume as the destination. To support
|
75
|
-
# this, we use a staging directory located under the cache path under the
|
76
|
-
# rather mild assumption that everything under the cache path is going to
|
77
|
-
# be on one device.
|
89
|
+
# Check if a given file (at absolute path) is missing or does has a mismatched md5sum
|
78
90
|
#
|
79
|
-
# @return [
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
# processes installing the same cookbook at the same time.
|
91
|
-
def staging_cache_key
|
92
|
-
"#{url_path.gsub(/[^[:alnum:]]/, "_")}_#{slug}"
|
91
|
+
# @return [TrueClass, FalseClass]
|
92
|
+
def file_outdated?(path, expected_md5sum)
|
93
|
+
return true unless File.exist?(path)
|
94
|
+
|
95
|
+
md5 = Digest::MD5.new
|
96
|
+
File.open(path, "r") do |file|
|
97
|
+
while (chunk = file.read(1024))
|
98
|
+
md5.update chunk
|
99
|
+
end
|
100
|
+
end
|
101
|
+
md5.to_s != expected_md5sum
|
93
102
|
end
|
94
103
|
end
|
95
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookbook-omnifetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2020-08-
|
16
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: mixlib-archive
|
@@ -74,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
74
|
requirements:
|
75
75
|
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '2.
|
77
|
+
version: '2.5'
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|