Xuanwo opened a new pull request, #8740:
URL: https://github.com/apache/opendal/pull/8740
# Which issue does this PR close?
Closes #.
# Rationale for this change
`FtpBackend` advertises `write_can_append: true`, but every append write
failed in `CompleteWriter::close()` with
`Unexpected: append result does not contain the final content length` —
after the bytes had already been appended on the server.
`CompleteWriter` requires the inner writer to return file `Metadata` with
the final content length for append writes, while `FtpWriter::close()`
unconditionally returned `MetadataBuilder::unknown()`. Closing an append
writer without writing anything hit the same path via `FtpLazyWriter`.
Reproduced against a real vsftpd server
(`fixtures/ftp/docker-compose-vsftpd.yml`):
- `test_write_with_append`, `test_write_with_append_returns_metadata`,
`test_writer_with_append` all failed before this change.
# What changes are included in this PR?
- `FtpWriter::close()` now opens the data stream when none was opened
(empty writes and empty appends still create or touch the remote file
via `APPE`), finalizes the transfer, renames the staged tmp file for
non-append writes as before, then queries `SIZE` on the target path
and returns `Metadata::file(size)`.
- `FtpLazyWriter::close()` now instantiates the inner writer on close
instead of returning unknown metadata, so closing a writer without
writes still creates the file and reports its metadata.
- `write_can_empty: true` is now advertised since empty writes create
the remote file.
Verification against local vsftpd (docker compose fixture):
- Before: `test_write_with_append`,
`test_write_with_append_returns_metadata`, `test_writer_with_append`
failed with `append result does not contain the final content length`.
- After: all 35 `test_write*` behavior tests pass.
- Remaining suite failures (`test_list_empty_dir`,
`test_list_nested_dir`, `test_list_dir_with_recursive*`,
`test_list_rich_dir`) reproduce identically on unmodified main and are
pre-existing vsftpd LIST-format issues unrelated to this change.
- `cargo clippy -p opendal-service-ftp --all-targets -- -D warnings` and
`cargo fmt --all -- --check` pass.
# Are there any user-facing changes?
Yes. `write_with(path, content).append(true)` on the FTP service now
succeeds and returns the file's final metadata instead of failing after
mutating the remote file. Empty writes now create an empty remote file,
matching the new `write_can_empty` capability.
# Breaking changes
# AI Usage Statement
- Harness: Pi coding agent (T3 Code orchestration, delegated task).
- Model: codex (sub-agent), with investigation verified by the author.
- Effort: default.
- Role: AI authored the change and ran the verification listed above
against a real local vsftpd server; the author reviewed the diff and
test results. Note: local behavior tests used a passive-port override
(30100-30199) because host ports 20000-20001 were already in use; the
upstream compose fixture is unchanged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]