ftp_patch_file
Apply a unified diff patch to a remote file for bandwidth-efficient updates with atomic consistency. Supports backup creation and drift protection via hash verification.
Instructions
Apply a Unified Diff patch to a remote file. RECOMMENDED: Use this instead of ftp_put_contents for updating existing files to minimize bandwidth and ensure atomic-like updates. For new files, use ftp_put_contents.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Remote path to the existing file to be patched. | |
| patch | Yes | The Unified Diff formatted string containing your local changes. | |
| createBackup | No | Generate a .bak copy of the remote file before applying the changes. | |
| expectedHash | No | Optional (but recommended): The SHA-256 hash of the remote file before patching to prevent race conditions (drift protection). |