Skip to content

Conversation

@cv711
Copy link
Contributor

@cv711 cv711 commented Dec 12, 2025

This pull request refactors and improves the S3 backup logic for asset snapshots, focusing on code reuse, error handling, and concurrency management. The main change is the extraction of the S3 object download logic into a reusable function, which simplifies the backup process for both private and public buckets. Additionally, the S3 downloader's concurrency and error propagation mechanisms are improved for reliability.

Refactoring and code reuse:

  • Extracted the S3 object download logic into a new helper function, processDownloadObject, which is now used for both private and public bucket backups. This reduces code duplication and centralizes file handling and error reporting. [1] [2]

Error handling and logging improvements:

  • Improved error reporting and logging in the backup process, ensuring that errors are logged with consistent messages and that context (such as the bucket name) is included in log entries.

S3 downloader concurrency and error propagation:

  • Enhanced the DownloadBucket method in S3Downloader to ensure that the error channel is properly closed after all goroutines complete, and that the first encountered error is returned immediately to halt further processing. Also added explicit comments and improved semaphore handling for clarity. [1] [2] [3] [4]

Minor improvements:

  • Added the strings package import to support directory/file checks in the new download logic.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the creation of snapshots for S3 objects by addressing concurrency issues in the download error handling and adding support for S3 directory objects (zero-byte objects with trailing slashes).

Key changes:

  • Simplified error handling in concurrent S3 downloads by using a buffered channel and proper goroutine synchronization
  • Refactored duplicate S3 download logic into a reusable helper function
  • Added special handling for S3 directory objects to prevent file creation errors

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/util/s3.go Fixed error channel buffering and simplified error propagation pattern in the S3 download bucket function
internal/snapshot/s3.go Refactored duplicate download logic into processDownloadObject helper function and added directory object handling
.gitignore Added .DS_Store to ignore macOS system files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cv711 cv711 merged commit 2d4b54b into main Dec 12, 2025
4 checks passed
@cv711 cv711 deleted the fix/snapshot-s3 branch December 12, 2025 12:49
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.

3 participants