prebake 0.3.8 → 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: 19a1c62dd2df6b16ab27629bda27ea6d6c18ae200c6e5874e1de7a17a642b643
4
- data.tar.gz: ddcba7e497fa98ce7955fb0c78804a64945f5a8d64b6fa017d56b23a32f624fe
3
+ metadata.gz: 3a9faf240c276429e13f29b8ac1b96042dbe56fbcb22718a1fe8e5a3d87b3647
4
+ data.tar.gz: '09075fab2ca5e7e79d1f1dc7c37cb0ab2fe7dba2d95de0526343817ac23ee76a'
5
5
  SHA512:
6
- metadata.gz: d5e9a824142b4bb5734a917ed9b52fc2ec75286fee31bd41129f0b7aeadffd4e918ff368a64a64e0262b365823e448d505f7a9e5af1d69380ba78c2cc816c74a
7
- data.tar.gz: 33687eb0a1d9ddf94b2b1773b2a9548783c93280c8731a1cc6c56bc598543ec339fdaebf336986b1f4727ef759795ea2dae048907b73fc5d715b4921c800fb2c
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)
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prebake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thejus Paul