github GlassHaven/Haven v5.24.98

latest releases: v5.94.65, v5.94.64, v5.94.63...
6 months ago

Fix: zero-byte destination when copying from SFTP / SMB / rclone to local storage

Reported by @slartibart70 in #142. Files copied from a remote backend to the phone landed with the right name but no contents.

Root cause

Phase 2 of cross-backend paste (remote → local) was passing the downloaded temp file's full size as a resume offset to the local writer. The function interpreted that as a real resume cursor — input.skip(size) advanced past every byte of the temp file before any were written, and FileOutputStream(append=true) opened a fresh empty destination. Result: 0-byte file.

Regression introduced in v5.24.12 (resumable paste queue) when resumeFromByte was added without distinguishing "progress display offset" from "transfer skip offset".

Fix

Split the two concerns. writeLocalFileWithProgress now takes progressOffset (display only) and transferOffset (skip + append cursor) as separate parameters. A new writeFileWithOptionalResume helper in LocalPasteIO.kt isolates the byte-copy core for unit testing, and the phase-2 call site passes transferOffset = 0 so the temp file's full content lands on disk. LOCAL → LOCAL paste keeps progressOffset = transferOffset = resumeFromByte (queue cursor covers both).

Tests

5 new tests in LocalPasteIOTest pin the contract:

  • transferOffset=0 overwrites destination with full source content
  • transferOffset=0 creates the destination when it doesn't exist (the GH#142 repro)
  • transferOffset>0 appends remainder of source past the offset
  • onChunk reports cumulative bytes written for the current call
  • negative transferOffset is rejected

Affected versions

Every release since v5.24.12 (2026-04-21) is affected. Upgrade to v5.24.98 to fix.


Verification on device: SFTP a file to phone → file lands with full bytes (matched against source via sha256sum or VLC playback).

Full Changelog: v5.24.97...v5.24.98

Don't miss a new Haven release

NewReleases is sending notifications on new releases.