A small service saves text notes into a tar archive through a passed IO object. After a recent change, complaints appeared: repeated operations with the same stream sometimes fail, and some notes in the archive end up empty.
You need to review the changes and find the causes of the regression. Fixing the code is not required in this task — it is important to identify the defects and their consequences according to the contract below.
ArchiveNoteStore#write accepts:
name: key with a string file name inside the archive;body: key with the note text;mtime: key with the modification time, defaulting to Time.now.notes/<name>.txt to the tar archive.IO passed in belongs to the caller:
archive_note_store.rb and archive_note_store_spec.rb.ruby archive_note_store_spec.rb
write, you can continue working with the same StringIO.notes/<name>.txt match the passed body: in full.IO.3.3stringio, minitest/autorun, rubygems/package, tmpdirruby archive_note_store_spec.rbUse line comments to explain the problem, its impact, the fix and how to test it.