scttnlsn / dandelion

Incremental Git repository deployment.
http://scttnlsn.github.io/dandelion
MIT License
738 stars 57 forks source link

Deploying corrupts image files #91

Closed nev7n closed 9 years ago

nev7n commented 10 years ago

When delpoying over sftp changed image files are uploaded but corrupted in the process. My dandelion.yml looks like this:

adapter: sftp
host: xxxx.co.uk
username: xxxxx
password: xxxxx
path: /home/xxxx

exclude:
    - .gitignore
    - dandelion.yml
    - folder/

My client machine is Windows 8.1 with Ruby 1.9.3, Server is CENTOS 6.5 x86_64.

It looks like it's treating binary files as text and converting line breaks. An example corrupted file is 926 bytes instead of 921 bytes and I can see extra '0x0D' characters inserted before '0x0A'.

Otherwise it all works a treat.

scttnlsn commented 10 years ago

@nev7n Thanks for reporting. I can't reproduce this on OS X so I'm guessing it might be specific to Windows.

Other Widows users: are you also experiencing this problem?

nev7n commented 10 years ago

I tried command line sftp from Windows to the same server and that worked OK, just incase the server was screwing the line endings.

I've not done any ruby before but had a quick dig through the code and my best guess is that opening the file using IO.Read in lib/deployer.rb is screwing up the line endings ( See http://techblog.leosoto.com/reading-binary-file-on-ruby/ ).

scttnlsn commented 10 years ago

Is the image versioned by Git or is it an extra file that is being deployed?

The first case is handled here (data is read out of Git): https://github.com/scttnlsn/dandelion/blob/master/lib/dandelion/tree.rb#L38 The latter case reads the file from the filesystem (IO.read): https://github.com/scttnlsn/dandelion/blob/master/lib/dandelion/deployer.rb#L42

Regardless, I should update those IO.read calls to handle binary files.

nev7n commented 10 years ago

The file was versioned by git, I guess a similar thing may be happening when reading the file there.

scttnlsn commented 9 years ago

I just updated Dandelion to use a new version of therugged gem (which in turn uses an updated version of libgit2). I noticed that the new libgit2 included some fix regarding line endings on Windows. Please try Dandelion v0.4.7 and reopen this issue if you're still having a problem.