Skip to content

Conversation

@ChaseDRedmon
Copy link
Owner

@ChaseDRedmon ChaseDRedmon commented Nov 30, 2025

This PR introduces several new features, improvements, and infrastructure updates to the CatBox.NET library.

🚀 New Features

Album File Limit Enforcement

  • Added MaxAlbumFiles constant (500) to centralize the CatBox album limit
  • Added CatBoxAlbumFileLimitExceededException for clear error handling when limits are exceeded
  • Added Throw.IfAlbumFileLimitExceeds() validation helper
  • Validation is now enforced in CreateAlbumAsync and ModifyAlbumAsync operations

Capacity-Aware Uploads

  • Added UploadImagesToAlbumSafeAsync() method that intelligently handles album capacity
  • Fetches album first to determine available space
  • Uploads only what fits within the 500-file limit
  • Returns AlbumUploadResult with detailed metrics:
    • Files uploaded / skipped / remaining capacity

GetAlbum API Support

  • Added GetAlbumAsync() to retrieve album information including file lists
  • New request/response models: GetAlbumRequest, AlbumInfo, GetAlbumApiResponse

File & Album Downloads

  • Added DownloadFileAsync() for single file downloads (skips if file exists)
  • Added DownloadAlbumAsync() for batch album downloads (yields FileInfo per file)
  • Supports both DirectoryInfo and string path overloads

URL Parsing Extensions

  • ToCatboxImageName() - extracts filename from CatBox URLs
  • ToAlbumShortCode() - extracts album ID from album URLs

⚡ Performance & Quality Improvements

Native AOT Compatibility

  • Enabled IsAotCompatible flag in project file
  • Added JSON source generation context (CatBoxJsonContext) for AOT scenarios
  • Added CatBoxApiErrorResponse model for structured JSON error handling

Async Best Practices

  • Added ToListAsync extension for IAsyncEnumerable
  • Replaced ToBlockingEnumerable() with proper async/await patterns
  • Added ConfigureAwait(false) throughout for library code best practices

Error Handling

  • Improved retry policy to not retry client errors (4xx)
  • Only retries HttpRequestException and server errors (5xx)
  • Enhanced JSON error parsing for API responses

🧪 Testing

  • Added unit tests for album file limit validation
  • Added unit tests for URL parsing extensions
  • Updated integration tests to use proper async/await patterns
  • 127 unit tests passing

📁 Files Changed

  • 24 files modified/added
  • 4 new response models created
  • 1 new request model created

ChaseDRedmon and others added 5 commits November 29, 2025 22:32
- Enable IsAotCompatible flag in project file
- Add JSON source generation context for AOT scenarios
- Add CatBoxApiErrorResponse model for structured error handling
- Configure ReSharper to enforce ConfigureAwait in library code
- Bump version to 1.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add MaxAlbumFiles constant (500) to Common class
- Add CatBoxAlbumFileLimitExceededException for limit violations
- Add Throw.IfAlbumFileLimitExceeds() validation helper
- Add AlbumUploadResult record for capacity-aware upload results
- Add URL parsing extensions (ToCatboxImageName, ToAlbumShortCode)
- Add ToListAsync extension for IAsyncEnumerable

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add RequestType.GetAlbum enum value
- Add GetAlbumRequest and response models (AlbumInfo, GetAlbumApiResponse)
- Add ICatBoxClient.GetAlbumAsync() for retrieving album information
- Add file download support with DownloadFileAsync methods
- Add album download with DownloadAlbumAsync (yields FileInfo per file)
- Add UploadImagesToAlbumSafeAsync for capacity-aware uploads
- Improve retry policy to not retry client errors (4xx)
- Add ConfigureAwait(false) throughout for library best practices
- Replace ToBlockingEnumerable with async/await patterns

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add tests for album file limit validation (IfAlbumFileLimitExceeds)
- Add tests for URL parsing extensions (ToCatboxImageName, ToAlbumShortCode)
- Update integration tests to use proper async/await patterns
- Improve test coverage for CatBox and Litterbox clients

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update VCS settings for branch protection

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ChaseDRedmon ChaseDRedmon self-assigned this Nov 30, 2025
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