prebake 0.3.7 → 0.3.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8773dbffbc19494a8ca48af28bf2d68bef4f4ebecae1fd37ff7ec171880b2c4d
4
- data.tar.gz: a3e243baec1fcebd091c3b7b466f65cb6f74b0cfc6ca5a9f69f81e46cbd2eea8
3
+ metadata.gz: 3a9faf240c276429e13f29b8ac1b96042dbe56fbcb22718a1fe8e5a3d87b3647
4
+ data.tar.gz: '09075fab2ca5e7e79d1f1dc7c37cb0ab2fe7dba2d95de0526343817ac23ee76a'
5
5
  SHA512:
6
- metadata.gz: efbb626624281ca0488cd549ffa3e8467c7601214153733d7e035c949c9b0c7c275b3668ea616c386b7d2726090e8309613ab7727295940c02fd6f23c1119ac9
7
- data.tar.gz: 0a0ce57c3e7bbd2f03c8d0c1f9d7883d2d8b46389a0dbaccfed45ae545be05b88fb2e7f40d45fc386ede90b778e3684564b5fafdf02f8765d7a3eb68311e6eec
6
+ metadata.gz: e57e53e423306d08e03dd50d8c31646785ca5b9ded9d252a63a343c33607e4653394e0289d3c575599b4424b69fb5d5bad306bac2c2a7678868aa66729cebdd9
7
+ data.tar.gz: ee212634e00c97d3b3e084be9f2cfffd7158819a006b965b61bcca3719544d50b5fb34f5e18fa2906c8fb0e65dc50fa7bb383e4c671ead2513876975c2f2b6cc
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "fileutils"
3
4
  require_relative "../logger"
4
5
 
5
6
  module Prebake
@@ -16,6 +17,9 @@ module Prebake
16
17
  def fetch_with_checksum(cache_key)
17
18
  path = fetch(cache_key)
18
19
  [path, path && fetch_checksum(cache_key)]
20
+ rescue StandardError
21
+ FileUtils.rm_f(path) if path
22
+ raise
19
23
  end
20
24
 
21
25
  def push(gem_path, cache_key, checksum)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "uri"
4
4
  require "securerandom"
5
+ require "fileutils"
5
6
  require_relative "base"
6
7
  require_relative "http_client"
7
8
  require_relative "../logger"
@@ -32,16 +33,19 @@ module Prebake
32
33
  return [nil, nil] unless path
33
34
 
34
35
  [path, checksum || fetch_checksum(cache_key)]
36
+ rescue StandardError
37
+ FileUtils.rm_f(path) if path
38
+ raise
35
39
  end
36
40
 
41
+ # nil means the server has no checksum file. Anything else that goes wrong
42
+ # raises, so a lookup that merely failed never gets a good cached gem deleted.
37
43
  def fetch_checksum(cache_key)
38
44
  response = http_request(:get, checksum_uri(cache_key))
39
- return nil unless response.is_a?(Net::HTTPSuccess)
45
+ return response.body.strip if response.is_a?(Net::HTTPSuccess)
46
+ return nil if response.is_a?(Net::HTTPNotFound)
40
47
 
41
- response.body.strip
42
- rescue StandardError => e
43
- Logger.debug "Checksum fetch failed for #{cache_key}: #{e.message}"
44
- nil
48
+ raise Error, "Checksum fetch for #{cache_key} returned #{response.code}"
45
49
  end
46
50
 
47
51
  def push(gem_path, cache_key, checksum)
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "net/http"
4
+ require "timeout"
4
5
 
5
6
  module Prebake
6
7
  module Backends
7
8
  module HttpClient
8
9
  TIMEOUT = 30
10
+ # Net::HTTP's timeouts restart on every read, so a trickling response needs a total cap.
11
+ DEADLINE = 10
9
12
  HTTP_METHODS = { get: Net::HTTP::Get, head: Net::HTTP::Head,
10
13
  post: Net::HTTP::Post, put: Net::HTTP::Put,
11
14
  delete: Net::HTTP::Delete }.freeze
@@ -13,18 +16,27 @@ module Prebake
13
16
  private
14
17
 
15
18
  def http_request(method, uri, body: nil)
19
+ # After one failed download the cache is likely struggling, so the rest of the install builds from source.
20
+ raise Error, "Skipped: an earlier request to the cache failed" if @unavailable && !body
21
+
16
22
  request = build_http_request(method, uri)
17
23
  if body
18
24
  request["Content-Type"] = "application/octet-stream"
19
25
  request.body = body
20
26
  end
21
27
 
22
- Net::HTTP.start(uri.host, uri.port,
23
- use_ssl: uri.scheme == "https",
24
- open_timeout: TIMEOUT,
25
- read_timeout: TIMEOUT) do |http|
26
- http.request(request)
28
+ # Uploads carry whole gems, so they keep only the per-phase timeouts.
29
+ Timeout.timeout(body ? nil : DEADLINE) do
30
+ Net::HTTP.start(uri.host, uri.port,
31
+ use_ssl: uri.scheme == "https",
32
+ open_timeout: TIMEOUT,
33
+ read_timeout: TIMEOUT) do |http|
34
+ http.request(request)
35
+ end
27
36
  end
37
+ rescue StandardError
38
+ @unavailable = true unless body
39
+ raise
28
40
  end
29
41
 
30
42
  def build_http_request(method, uri)
@@ -31,8 +31,7 @@ module Prebake
31
31
  def fetch_checksum(cache_key)
32
32
  response = client.get_object(bucket: @bucket, key: checksum_key(cache_key))
33
33
  response.body.read.strip
34
- rescue StandardError => e
35
- Logger.debug "S3 checksum fetch failed for #{cache_key}: #{e.message}"
34
+ rescue Aws::S3::Errors::NoSuchKey
36
35
  nil
37
36
  end
38
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prebake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thejus Paul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-26 00:00:00.000000000 Z
11
+ date: 2026-10-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Prebake speeds up bundle install by skipping native gem compilation.
14
14
  It fetches precompiled binaries for gems like puma, nokogiri, pg, grpc, and bootsnap