Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-2946

FileUtils implementation broke compare_stream

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 3.6.2
    • Fix Version/s: PUP 3.7.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      0
    • Sprint:
      2014-09-03

      Description

      FileUtils.compare_stream implementation in ruby 1.9.3 was doing something along the lines of

          a = b = nil
          while something
            a = as.read size
            b = bs.read size
            return false if a != b
          end
      

      FileUtils.compare_stream in 2.0 instead does this:

          a = ""
          b = ""
          while something
            as.read size, a
            bs.read size, b
            return false if a != b
          end
      

      which is a problem since default encoding for strings is UTF-8 and when File#read reads into UTF-8 string it remains UTF-8 but when StringIO#read reads into UTF-8 string it becomes encoding of StringIO source string, which is ASCII for FileBucket::File contents.

      This leads to problems with backing up files and under certain conditions gives errors like:

      Error: Could not back up /bin/whatever.pyc: Got passed new contents for sum {md5}ca60cf7b168557fb8c34be106b8c4ae8

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              maksym Maksym Melnychok
              QA Contact:
              Eric Thompson
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support