baza.rb 0.9.3 → 0.9.5

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: 1dc6218bb18b7baff1acf3119b775c05a7fc1200d8fe6bea72de26e052be2028
4
- data.tar.gz: 4b58db5eda95b13edea4b09a223a3d787a4cbeffc80eb0025b8a16f2ed587fd6
3
+ metadata.gz: aef802e2941e27ceb8b0db8f2d19fe4bc0108de161f076dba14c8a7fa3aa4b46
4
+ data.tar.gz: 2eeff3f680e3792a45286fc484d02bcd90682e5469bd0a608d9bef86c4ba64e7
5
5
  SHA512:
6
- metadata.gz: a444b7f90eb26e3517e40d01ddcb1654b1ed7e027c397e0892ee01d5be286872910c7124317a187f55ecb9ac6d437d0d7055496cedb52a0a69c59158b3ba447d
7
- data.tar.gz: cc40e75452008681775d7428861f161058f1fa6b3127e0d80c84e1a29296e75bb76a3554920614fa42d5393a2bb67d37fb3906376ed63c121f1135f7233d5c46
6
+ metadata.gz: 20143f780ef916617d3f447dd703a713b874a7787c6ef4c11123f4df03a1ccb4136266dc50e570733d3c54d126a2b24a9b249c0d38e7033d47e695d4ba13170b
7
+ data.tar.gz: d123d577520dbe5cf41fcbf79f9bc7b03a8e10c83a06c0012fdc355e55b1e9c9d989534f7fa51150a9e9ffc95f358df0547c47d991516cf4c1278cf642f5f173
data/Gemfile.lock CHANGED
@@ -51,9 +51,9 @@ GEM
51
51
  logger
52
52
  faraday-http-cache (2.5.1)
53
53
  faraday (>= 0.8)
54
- faraday-multipart (1.1.0)
54
+ faraday-multipart (1.1.1)
55
55
  multipart-post (~> 2.0)
56
- faraday-net_http (3.4.0)
56
+ faraday-net_http (3.4.1)
57
57
  net-http (>= 0.5.0)
58
58
  faraday-retry (2.3.1)
59
59
  faraday (~> 2.0)
@@ -122,7 +122,7 @@ GEM
122
122
  regexp_parser (2.10.0)
123
123
  retries (0.0.5)
124
124
  rexml (3.4.1)
125
- rubocop (1.76.1)
125
+ rubocop (1.76.2)
126
126
  json (~> 2.3)
127
127
  language_server-protocol (~> 3.17.0.2)
128
128
  lint_roller (~> 1.1.0)
@@ -130,7 +130,7 @@ GEM
130
130
  parser (>= 3.3.0.2)
131
131
  rainbow (>= 2.2.2, < 4.0)
132
132
  regexp_parser (>= 2.9.3, < 3.0)
133
- rubocop-ast (>= 1.45.0, < 2.0)
133
+ rubocop-ast (>= 1.45.1, < 2.0)
134
134
  ruby-progressbar (~> 1.7)
135
135
  unicode-display_width (>= 2.4.0, < 4.0)
136
136
  rubocop-ast (1.45.1)
@@ -13,5 +13,5 @@
13
13
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
14
14
  # License:: MIT
15
15
  class BazaRb
16
- VERSION = '0.9.3'
16
+ VERSION = '0.9.5'
17
17
  end
data/lib/baza-rb.rb CHANGED
@@ -322,6 +322,7 @@ class BazaRb
322
322
  # @raise [ServerFailure] If the save operation fails
323
323
  def durable_save(id, file, chunk_size: 1_000_000)
324
324
  raise 'The ID of the durable is nil' if id.nil?
325
+ raise 'The ID of the durable must be an Integer' unless id.is_a?(Integer)
325
326
  raise 'The ID of the durable must be a positive integer' unless id.positive?
326
327
  raise 'The "file" of the durable is nil' if file.nil?
327
328
  raise "The file '#{file}' is absent" unless File.exist?(file)
@@ -338,6 +339,7 @@ class BazaRb
338
339
  # @raise [ServerFailure] If the load operation fails
339
340
  def durable_load(id, file)
340
341
  raise 'The ID of the durable is nil' if id.nil?
342
+ raise 'The ID of the durable must be an Integer' unless id.is_a?(Integer)
341
343
  raise 'The ID of the durable must be a positive integer' unless id.positive?
342
344
  raise 'The "file" of the durable is nil' if file.nil?
343
345
  elapsed(@loog) do
@@ -353,6 +355,7 @@ class BazaRb
353
355
  # @raise [ServerFailure] If the lock operation fails
354
356
  def durable_lock(id, owner)
355
357
  raise 'The ID of the durable is nil' if id.nil?
358
+ raise 'The ID of the durable must be an Integer' unless id.is_a?(Integer)
356
359
  raise 'The ID of the durable must be a positive integer' unless id.positive?
357
360
  raise 'The "owner" of the lock is nil' if owner.nil?
358
361
  raise 'The "owner" of the lock may not be empty' if owner.empty?
@@ -372,6 +375,7 @@ class BazaRb
372
375
  # @raise [ServerFailure] If the unlock operation fails
373
376
  def durable_unlock(id, owner)
374
377
  raise 'The ID of the durable is nil' if id.nil?
378
+ raise 'The ID of the durable must be an Integer' unless id.is_a?(Integer)
375
379
  raise 'The ID of the durable must be a positive integer' unless id.positive?
376
380
  raise 'The "owner" of the lock is nil' if owner.nil?
377
381
  raise 'The "owner" of the lock may not be empty' if owner.empty?
@@ -761,7 +765,8 @@ class BazaRb
761
765
  ('in gzip' if ret.headers['Content-Encoding'] == 'gzip'),
762
766
  ("ranged as #{ret.headers['Content-Range'].inspect}" if ret.headers['Content-Range'])
763
767
  ]
764
- ret = checked(ret, [200, 206])
768
+ ret = checked(ret, [200, 206, 302])
769
+ next if ret.code == 302
765
770
  if ret.headers['Content-Encoding'] == 'gzip'
766
771
  begin
767
772
  slice = unzip(slice)
@@ -783,6 +788,7 @@ class BazaRb
783
788
  raise "Range is not valid (#{range.inspect})" unless e.match?(/^[0-9]+$/)
784
789
  len = ret.headers['Content-Length'].to_i
785
790
  break if e.to_i == total.to_i - 1
791
+ break if total == '0'
786
792
  chunk += 1
787
793
  sleep(1) if len.zero?
788
794
  end
data/test/test_baza-rb.rb CHANGED
@@ -480,6 +480,18 @@ class TestBazaRb < Minitest::Test
480
480
  end
481
481
  end
482
482
 
483
+ def test_durable_load_empty_content
484
+ WebMock.disable_net_connect!
485
+ Dir.mktmpdir do |dir|
486
+ file = File.join(dir, 'loaded.txt')
487
+ stub_request(:get, 'https://example.org:443/durables/42')
488
+ .with(headers: { 'X-Zerocracy-Token' => '000' })
489
+ .to_return(status: 206, body: '', headers: { 'Content-Range' => 'bytes 0-0/0' })
490
+ fake_baza.durable_load(42, file)
491
+ assert_equal('', File.read(file))
492
+ end
493
+ end
494
+
483
495
  def test_durable_load_in_chunks
484
496
  WebMock.disable_net_connect!
485
497
  Dir.mktmpdir do |dir|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baza.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko