DEV: Raise errors when cleaning the download cache, and fix for macOS (PR #8319)

POSIX’s head specification states: “The application shall ensure that the number option-argument is a positive decimal integer”

Negative values are supported on GNU head, so this works in the discourse docker image. However, in some environments (e.g. macOS), the system head version fails with a negative n parameter.

This commit does two things

  • Adds pipefail to the cleanup command, so it cannot fail silently
  • Flip the ls command to list in descending time order, and use tail -n +501 instead of head -n -500.

GitHub

You’ve signed the CLA, davidtaylorhq. Thank you! This pull request is ready for review.