clj-commons / byte-streams

A Rosetta stone for JVM byte representations
417 stars 33 forks source link

Fixes transfers to File when `append?` is true #56

Closed KingMob closed 2 years ago

KingMob commented 2 years ago

Fixes #23...I think.

I have no idea why it would have worked on Linux, but not a Mac. I believe append-mode for File transfers should have been broken for all platforms, except when "appending" to empty files.

The current fix calls .position() on the FileChannel to know where to start. Normally a fresh FC will be at 0, except in append mode, when .position() will always return the current size of the file.

This doesn't handle multiple writers correctly, since it never calls .position() again, but there's a lot more work to do to make byte-streams compatible with that assumption, so we're not tackling that here.