Skip to content

Close owned transfer files when the channel closes with an error - #89

Open
OskarEichler wants to merge 1 commit into
net-ssh:masterfrom
OskarEichler:codex/close-owned-files
Open

Close owned transfer files when the channel closes with an error#89
OskarEichler wants to merge 1 commit into
net-ssh:masterfrom
OskarEichler:codex/close-owned-files

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Close library-owned upload/download files in an ensure clause when a channel closes, including when exit-status validation raises. Leave caller-owned IO open.

Reproduction and evidence

Closes #20. A download receiving C0644 6 file opens its destination; a subsequent nonzero channel exit raises Net::SCP::Error but previously left that file descriptor open. The public-entrypoint channel simulation now observes the original error and a closed file. Additional models cover upload/download, nonzero/missing exit status, already closed files and caller-owned File/StringIO behavior.

Compatibility / breaking changes

No API or dependency change; existing transfer errors remain errors. This handles channel-close cleanup, not all exceptions from user progress callbacks or an abandoned channel that is never closed. No broader lifecycle guarantee is claimed.

Verification and limits

  • This focused branch passes the existing upstream suite: 36 tests / 70 assertions, Ruby 4.0.6, net-ssh 7.3.3, test-unit 3.7.8 and Mocha 2.1.0; all Ruby commands used rbenv.
  • The combined release-based consumer candidate passes the suite with frozen string literals enabled, 10 focused cases, 2,906 model assertions, 24 URI-component assertions and 19 local scp/URI assertions. Combined evidence includes other separately proposed fixes and existing upstream frozen-string corrections; it is not attributed to this patch alone.
  • No repository tests added/modified under the consuming project's explicit no-new-tests policy. Reproductions/models ran externally. No deployed servers, SSH connections or production data were used.
  • All seven runtime files parse with the Ruby 2.6 parser; actual older-Ruby/Windows/remote-server matrices were not run locally. No upstream lint config exists; targeted lint has the same eight pre-existing warnings, with no new warnings.
  • Existing upstream PRs/issues and contribution guidance were checked. Maintainer CI results are pending; no CI pass is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File remains locked if scp returns non-zero

1 participant