minitar 0.8 → 0.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: 1440e1c57cdd811497e6717a6f81791816bfb2ec5dce0981d9208c41bcd6f09d
4
- data.tar.gz: e36cf70bd9acc32d73c95a48c1e67f494853f47603032cac05a84bd366417655
3
+ metadata.gz: 81012ea81faa48803820b1eb4c26fd7a305bd1a2065a748b6dee20ee42e0034a
4
+ data.tar.gz: '00875c99346e1b1d77c75c08d22111903ea5bc65b0d82caee885a6984209c5af'
5
5
  SHA512:
6
- metadata.gz: b615673d6e6626606e6e858d453af056870f4b8c88dade5641595b35733491e6dfe2ec32e90d28f7585308a4229f2ace63b47224c0b2877b44c5b028ee3c1031
7
- data.tar.gz: ea2adda3fdcf9314c325cfa69f7ae5bbf6bc02732c8b131acef7406c45c4c53906a5612940fdc6d026d2fcda809b3a095abbe90bcf96a19f4082a653dcf8cbc3
6
+ metadata.gz: b47a400a37432b732b662a3c374b2bb1a36b36ea3c92b58db872cb1efc8be0036d708716305f19840ab5f1d0b76a2b4331273e6c6339bc42a003b74c450e79c4
7
+ data.tar.gz: 32b4f62fac25b7bc4ff0ba3d2f28e5a3d761eb62c7e4f2b9330a3be95cee31eda82f6a6c6c0883a8ea4c26d3735c17aec922ab29b3b18372cf7e86b9fe425370
@@ -69,21 +69,22 @@ Here's the most direct way to get your work merged into the project:
69
69
 
70
70
  Thanks to everyone who has contributed to minitar:
71
71
 
72
+ * Akinori MUSHA (knu)
72
73
  * Antoine Toulme
73
74
  * Curtis Sampson
74
75
  * Daniel J. Berger
76
+ * Jorie Tappa
77
+ * Kazuyoshi Kato
75
78
  * Kazuyoshi Kato
79
+ * Kevin McDermott
76
80
  * Matthew Kent
77
81
  * Michal Suchanek
78
82
  * Mike Furr
79
83
  * Pete Fritchman
80
84
  * Zach Dennis
81
- * ooooooo\_q
82
- * Kazuyoshi Kato
83
85
  * dearblue
84
- * Kevin McDermott
85
86
  * inkstak
86
- * Akinori MUSHA (knu)
87
+ * ooooooo\_q
87
88
 
88
89
  [Minitest]: https://github.com/seattlerb/minitest
89
90
  [quality commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
data/History.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.9 / 2019-09-04
2
+
3
+ * jtappa added the ability to skip fsync with a new option to Minitar.unpack
4
+ and Minitar::Input#extract_entry. Provide `:fsync => false` as the last
5
+ parameter to enable. Merged from a modified version of PR [#37][].
6
+
1
7
  ## 0.8 / 2019-01-05
2
8
 
3
9
  * inkstak resolved an issue introduced in the fix for [#31][] by allowing
@@ -161,3 +167,4 @@
161
167
  [#33]: https://github.com/halostatue/minitar/issues/33
162
168
  [#35]: https://github.com/halostatue/minitar/issues/35
163
169
  [#36]: https://github.com/halostatue/minitar/issues/36
170
+ [#37]: https://github.com/halostatue/minitar/issues/37
@@ -14,24 +14,9 @@ coveralls :: {<img src="https://coveralls.io/repos/halostatue/minitar/badge.svg"
14
14
  The minitar library is a pure-Ruby library that provides the ability to deal
15
15
  with POSIX tar(1) archive files.
16
16
 
17
- This is release 0.7, providing fixes for several issues and clarifying the
18
- Minitar security stance. There are two minor breaking changes in this version
19
- so that exceptions will be thrown if a negative size is provided in a tar
20
- stream header or if the tar stream header is otherwise invalid.
21
-
22
- This release continues the migration and modernization of the code:
23
-
24
- * the licence has been changed to match the modern Ruby licensing scheme
25
- (Ruby and Simplified BSD instead of Ruby and GNU GPL);
26
- * the +minitar+ command-line program has been separated into the
27
- +minitar-cli+ gem; and
28
- * the +archive-tar-minitar+ gem now points to the +minitar+ and +minitar-cli+
29
- gems and discourages its installation.
30
-
31
- Some of these changes may break existing programs that depend on the internal
32
- structure of the minitar library, but every effort has been made to ensure
33
- compatibility; inasmuch as is possible, this compatibility will be maintained
34
- through the release of minitar 1.0 (which will have strong breaking changes).
17
+ This is release 0.9, adding a minor feature to Minitar.unpack and
18
+ Minitar::Input#extract_entry that when <tt>:fsync => false</tt> is provided,
19
+ fsync will be skipped.
35
20
 
36
21
  minitar (previously called Archive::Tar::Minitar) is based heavily on code
37
22
  originally written by Mauricio Julio Fernández Pradier for the rpa-base
@@ -73,7 +73,7 @@ end
73
73
  # tar.close
74
74
  # end
75
75
  module Archive::Tar::Minitar
76
- VERSION = '0.8'.freeze # :nodoc:
76
+ VERSION = '0.9'.freeze # :nodoc:
77
77
 
78
78
  # The base class for any minitar error.
79
79
  Error = Class.new(::StandardError)
@@ -245,7 +245,7 @@ module Archive::Tar::Minitar
245
245
  # A convenience method to unpack files from +src+ into the directory
246
246
  # specified by +dest+. Only those files named explicitly in +files+
247
247
  # will be extracted.
248
- def unpack(src, dest, files = [], &block)
248
+ def unpack(src, dest, files = [], options = {}, &block)
249
249
  Input.open(src) do |inp|
250
250
  if File.exist?(dest) and !dir?(dest)
251
251
  raise %q(Can't unpack to a non-directory.)
@@ -255,7 +255,7 @@ module Archive::Tar::Minitar
255
255
 
256
256
  inp.each do |entry|
257
257
  if files.empty? or files.include?(entry.full_name)
258
- inp.extract_entry(dest, entry, &block)
258
+ inp.extract_entry(dest, entry, options, &block)
259
259
  end
260
260
  end
261
261
  end
@@ -19,14 +19,17 @@ module Archive::Tar::Minitar
19
19
  # Archive::Tar::Minitar::Input.open(io) { |input| block } -> obj
20
20
  def self.open(input)
21
21
  stream = new(input)
22
- return stream unless block_given?
23
-
24
- # This exception context must remain, otherwise the stream closes on open
25
- # even if a block is not given.
26
- begin
27
- yield stream
28
- ensure
29
- stream.close
22
+
23
+ if block_given?
24
+ # This exception context must remain, otherwise the stream closes on
25
+ # open even if a block is not given.
26
+ begin
27
+ yield stream
28
+ ensure
29
+ stream.close
30
+ end
31
+ else
32
+ stream
30
33
  end
31
34
  end
32
35
 
@@ -114,7 +117,7 @@ module Archive::Tar::Minitar
114
117
  # cycle.
115
118
  # <tt>:entry</tt>:: The entry being extracted; this is a
116
119
  # Reader::EntryStream, with all methods thereof.
117
- def extract_entry(destdir, entry) # :yields action, name, stats:
120
+ def extract_entry(destdir, entry, options = {}, &block) # :yields action, name, stats:
118
121
  stats = {
119
122
  :current => 0,
120
123
  :currinc => 0,
@@ -137,59 +140,9 @@ module Archive::Tar::Minitar
137
140
  end
138
141
 
139
142
  if entry.directory?
140
- dest = File.join(destdir, full_name)
141
-
142
- yield :dir, full_name, stats if block_given?
143
-
144
- if Archive::Tar::Minitar.dir?(dest)
145
- begin
146
- FileUtils.chmod(entry.mode, dest)
147
- rescue
148
- nil
149
- end
150
- else
151
- File.unlink(dest.chomp('/')) if File.symlink?(dest.chomp('/'))
152
-
153
- FileUtils.mkdir_p(dest, :mode => entry.mode)
154
- FileUtils.chmod(entry.mode, dest)
155
- end
156
-
157
- fsync_dir(dest)
158
- fsync_dir(File.join(dest, '..'))
159
- return
143
+ extract_directory(destdir, full_name, entry, stats, options, &block)
160
144
  else # it's a file
161
- destdir = File.join(destdir, File.dirname(full_name))
162
- FileUtils.mkdir_p(destdir, :mode => 0o755)
163
-
164
- destfile = File.join(destdir, File.basename(full_name))
165
-
166
- File.unlink(destfile) if File.symlink?(destfile)
167
-
168
- # Errno::ENOENT
169
- # rubocop:disable Style/RescueModifier
170
- FileUtils.chmod(0o600, destfile) rescue nil
171
- # rubocop:enable Style/RescueModifier
172
-
173
- yield :file_start, full_name, stats if block_given?
174
-
175
- File.open(destfile, 'wb', entry.mode) do |os|
176
- loop do
177
- data = entry.read(4096)
178
- break unless data
179
-
180
- stats[:currinc] = os.write(data)
181
- stats[:current] += stats[:currinc]
182
-
183
- yield :file_progress, full_name, stats if block_given?
184
- end
185
- os.fsync
186
- end
187
-
188
- FileUtils.chmod(entry.mode, destfile)
189
- fsync_dir(File.dirname(destfile))
190
- fsync_dir(File.join(File.dirname(destfile), '..'))
191
-
192
- yield :file_done, full_name, stats if block_given?
145
+ extract_file(destdir, full_name, entry, stats, options, &block)
193
146
  end
194
147
  end
195
148
 
@@ -218,5 +171,73 @@ module Archive::Tar::Minitar
218
171
  ensure
219
172
  dir.close if dir rescue nil # rubocop:disable Style/RescueModifier
220
173
  end
174
+
175
+ def extract_directory(destdir, full_name, entry, stats, options)
176
+ dest = File.join(destdir, full_name)
177
+
178
+ yield :dir, full_name, stats if block_given?
179
+
180
+ if Archive::Tar::Minitar.dir?(dest)
181
+ begin
182
+ FileUtils.chmod(entry.mode, dest)
183
+ rescue
184
+ nil
185
+ end
186
+ else
187
+ File.unlink(dest.chomp('/')) if File.symlink?(dest.chomp('/'))
188
+
189
+ FileUtils.mkdir_p(dest, :mode => entry.mode)
190
+ FileUtils.chmod(entry.mode, dest)
191
+ end
192
+
193
+ if options.fetch(:fsync, true)
194
+ fsync_dir(dest)
195
+ fsync_dir(File.join(dest, '..'))
196
+ end
197
+ end
198
+
199
+ def extract_file(destdir, full_name, entry, stats, options)
200
+ destdir = File.join(destdir, File.dirname(full_name))
201
+ FileUtils.mkdir_p(destdir, :mode => 0o755)
202
+
203
+ destfile = File.join(destdir, File.basename(full_name))
204
+
205
+ File.unlink(destfile) if File.symlink?(destfile)
206
+
207
+ # Errno::ENOENT
208
+ # rubocop:disable Style/RescueModifier
209
+ FileUtils.chmod(0o600, destfile) rescue nil
210
+ # rubocop:enable Style/RescueModifier
211
+
212
+ yield :file_start, full_name, stats if block_given?
213
+
214
+ File.open(destfile, 'wb', entry.mode) do |os|
215
+ loop do
216
+ data = entry.read(4096)
217
+ break unless data
218
+
219
+ stats[:currinc] = os.write(data)
220
+ stats[:current] += stats[:currinc]
221
+
222
+ yield :file_progress, full_name, stats if block_given?
223
+ end
224
+
225
+ if options.fetch(:fsync, true)
226
+ yield :file_fsync, full_name, stats if block_given?
227
+ os.fsync
228
+ end
229
+ end
230
+
231
+ FileUtils.chmod(entry.mode, destfile)
232
+
233
+ if options.fetch(:fsync, true)
234
+ yield :dir_fsync, full_name, stats if block_given?
235
+
236
+ fsync_dir(File.dirname(destfile))
237
+ fsync_dir(File.join(File.dirname(destfile), '..'))
238
+ end
239
+
240
+ yield :file_done, full_name, stats if block_given?
241
+ end
221
242
  end
222
243
  end
@@ -216,4 +216,12 @@ UTAKRsEoGAWjYBSMglFACgAAuUHUvwAoAAA=
216
216
  reader = Zlib::GzipReader.new(StringIO.new(OCTAL_WRAPPED_BY_SPACE_TGZ))
217
217
  Minitar.unpack(reader, 'data__', [])
218
218
  end
219
+
220
+ def test_fsync_false
221
+ outer = 0
222
+ Minitar.unpack(Zlib::GzipReader.new(StringIO.new(TEST_TGZ)), 'data__', [], :fsync => false) do |_label, _path, _stats|
223
+ outer += 1
224
+ end
225
+ assert_equal(6, outer)
226
+ end
219
227
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitar
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Ziegler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-05 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -154,36 +154,21 @@ dependencies:
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: '3.17'
157
+ version: '3.18'
158
158
  type: :development
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
- version: '3.17'
164
+ version: '3.18'
165
165
  description: |-
166
166
  The minitar library is a pure-Ruby library that provides the ability to deal
167
167
  with POSIX tar(1) archive files.
168
168
 
169
- This is release 0.7, providing fixes for several issues and clarifying the
170
- Minitar security stance. There are two minor breaking changes in this version
171
- so that exceptions will be thrown if a negative size is provided in a tar
172
- stream header or if the tar stream header is otherwise invalid.
173
-
174
- This release continues the migration and modernization of the code:
175
-
176
- * the licence has been changed to match the modern Ruby licensing scheme
177
- (Ruby and Simplified BSD instead of Ruby and GNU GPL);
178
- * the +minitar+ command-line program has been separated into the
179
- +minitar-cli+ gem; and
180
- * the +archive-tar-minitar+ gem now points to the +minitar+ and +minitar-cli+
181
- gems and discourages its installation.
182
-
183
- Some of these changes may break existing programs that depend on the internal
184
- structure of the minitar library, but every effort has been made to ensure
185
- compatibility; inasmuch as is possible, this compatibility will be maintained
186
- through the release of minitar 1.0 (which will have strong breaking changes).
169
+ This is release 0.9, adding a minor feature to Minitar.unpack and
170
+ Minitar::Input#extract_entry that when <tt>:fsync => false</tt> is provided,
171
+ fsync will be skipped.
187
172
 
188
173
  minitar (previously called Archive::Tar::Minitar) is based heavily on code
189
174
  originally written by Mauricio Julio Fernández Pradier for the rpa-base
@@ -250,8 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
235
  - !ruby/object:Gem::Version
251
236
  version: '0'
252
237
  requirements: []
253
- rubyforge_project:
254
- rubygems_version: 2.7.7
238
+ rubygems_version: 3.0.3
255
239
  signing_key:
256
240
  specification_version: 4
257
241
  summary: The minitar library is a pure-Ruby library that provides the ability to deal