Skip to content

Add pull:files-archive command - #2036

Open
grasmash wants to merge 3 commits into
mainfrom
files-archive-download
Open

Add pull:files-archive command#2036
grasmash wants to merge 3 commits into
mainfrom
files-archive-download

Conversation

@grasmash

Copy link
Copy Markdown
Contributor

Motivation

pull:files requires a local rsync binary. That's a real friction point on Windows (no rsync out of the box) and in minimal CI containers, and rsync behavior varies across the client versions in the wild (rsync 2.x on older macOS, rsync 3.x, and Apple's openrsync all differ). This adds an alternative that needs only ssh and tar locally.

Proposed changes

Adds a new pull:files-archive command. It accepts the same arguments as pull:files (environment, site, site instance) and copies the environment's public files to the local files directory by:

  1. Running a single fixed remote command over SSH — tar -C <files-dir> -czf - . — and redirecting the streamed tarball to a local temp file. The process exit code is the remote tar's, so download failures are reported directly.
  2. Extracting the tarball into docroot/sites/<site>/files with the local tar, as a separate, separately-reported step.

The temp tarball is removed in a finally block either way. Dynamic values (SSH URL, remote path, temp path) are passed via Symfony Process "${:VAR}" placeholders rather than string interpolation.

pull:files is unchanged; this is purely additive.

Alternatives considered

  • Bundling or requiring rsync: heavier dependency, and client-version variance is exactly the problem.
  • Piping ssh ... | tar -xzf - directly: loses the remote exit code without pipefail, which /bin/sh doesn't support portably. The two-step download-then-extract keeps error reporting exact.

Testing steps

  1. Follow the contribution guide to set up your development environment or download a pre-built acli.phar for this PR.
  2. If running from source, clear the kernel cache to pick up new and changed commands: ./bin/acli ckc
  3. Check for regressions: run acli pull:files against an environment and confirm it still syncs files.
  4. Check new functionality: from a project directory, run acli pull:files-archive, choose an application/environment/site, and confirm the files land in docroot/sites/<site>/files. Delete a local file and re-run to confirm it's restored.

Adds a pull:files-archive command that copies Drupal public files from a
Cloud Platform environment by streaming a gzipped tarball over SSH and
extracting it locally. Unlike pull:files, it does not require a local
rsync binary (only ssh and tar), which makes it usable on Windows and in
minimal CI containers, and it issues a single fixed remote command with
straightforward failure modes: the download process exit code is the
remote tar's, and extraction is a separate, separately-reported step.
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.51%. Comparing base (9afe4e7) to head (12ae085).

Files with missing lines Patch % Lines
src/Command/Pull/PullCommandBase.php 93.75% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2036      +/-   ##
============================================
+ Coverage     92.49%   92.51%   +0.01%     
- Complexity     1995     2002       +7     
============================================
  Files           123      124       +1     
  Lines          7238     7280      +42     
============================================
+ Hits           6695     6735      +40     
- Misses          543      545       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/2036/acli.phar

curl -OL https://acquia-cli.s3.amazonaws.com/build/pr/2036/acli.phar
chmod +x acli.phar

- Assert production environments are offered (kills the TrueValue
  mutant on determineEnvironment's allowProduction argument).
- Mock the Filesystem and require mkdir and temp-tarball removal
  (kills the mkdir MethodCallRemoval, the finally-block remove
  MethodCallRemoval, and the UnwrapFinally mutants).
- Assert the interpolated exception message (kills the ArrayItem and
  ArrayItemRemoval mutants on the error context array).
- Ignore Checklist addItem/completePreviousItem in Infection: they only
  render via the spinner, which is disabled without a TTY, so they are
  not observable in a unit test (same rationale as the existing logger
  ignore).
tempnam() truncates the prefix to three characters on Windows, so the
temp tarball path cannot be matched by prefix; match any string. Assert
temp-tarball cleanup in the failure test as well, since the finally
block is only observable when the download throws.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant