Skip to content

Conversation

@Luc-cpl
Copy link

@Luc-cpl Luc-cpl commented Jan 16, 2026

This pull request significantly enhances the S3 stream wrapper by adding robust support for renaming directories (not just files) within S3 buckets, ensuring correct handling of special characters in object keys (such as spaces and parentheses), and improving test coverage for these scenarios. The update introduces batch operations for efficient directory renames and adds comprehensive tests to verify correct behavior and encoding.

Major enhancements to S3 stream wrapper directory rename functionality:

  • Added support for renaming directories (not just single files) by recursively copying all objects under the source prefix to the new destination, then deleting the originals, using AWS S3 batch operations for efficiency. This includes handling directory markers and cache invalidation.
  • Implemented the isDirectoryPrefix helper to accurately detect when a given key represents a directory (prefix) in S3, ensuring the correct rename logic is applied.
  • Introduced the encodeCopySource method to correctly URL-encode each path segment for S3's CopySource parameter, preventing failures when object keys contain spaces or special characters.

Test improvements and validation:

  • Added extensive tests for directory renaming, including cases with nested files, empty directories, and files with special characters in their names, to ensure the new logic works as intended.
  • Included tests to verify that the encodeCopySource method is used in the directory rename implementation and that file renames with special characters succeed.

Dependency update:

  • Added import of Aws\CommandPool to enable batch operations for copying objects in directory renames.

@Luc-cpl Luc-cpl marked this pull request as ready for review January 16, 2026 23:28
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.

2 participants