Skip to content

Comments

GetAlbum and DownloadAlbum / Files#9

Merged
ChaseDRedmon merged 8 commits intomainfrom
feature/GetAlbum
Feb 19, 2026
Merged

GetAlbum and DownloadAlbum / Files#9
ChaseDRedmon merged 8 commits intomainfrom
feature/GetAlbum

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
@github-actions
Copy link

Qodana Community for .NET

60 new problems were found

Inspection name Severity Problems
Redundant nullable warning suppression expression 🔶 Warning 8
Do not use object initializer for 'using' variable: Do not use object initializer for 'using' variable 🔶 Warning 8
Redundant using directive 🔶 Warning 7
Conditional access qualifier expression is not null according to nullable reference types' annotations 🔶 Warning 5
Inconsistent Naming 🔶 Warning 5
Namespace does not correspond to file location 🔶 Warning 3
Auto-property accessor is never used: Non-private accessibility 🔶 Warning 3
Use of obsolete symbol 🔶 Warning 1
Expression is always 'true' or 'false' according to nullable reference types' annotations 🔶 Warning 1
Invalid XML documentation comment 🔶 Warning 1
Type member is never used: Non-private accessibility ◽️ Notice 7
Type member is never accessed via base type: Non-private accessibility ◽️ Notice 3
Use UTF-8 string literal ◽️ Notice 2
Auto-property can be made get-only: Non-private accessibility ◽️ Notice 1
Class is never instantiated: Non-private accessibility ◽️ Notice 1
'if' statement can be rewritten as '?:' expression ◽️ Notice 1
Convert into lambda expression ◽️ Notice 1
Redundant string interpolation ◽️ Notice 1
Type is never used: Non-private accessibility ◽️ Notice 1
View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2025.2.3
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@ChaseDRedmon ChaseDRedmon merged commit 88ec38c into main Feb 19, 2026
2 checks passed
@ChaseDRedmon ChaseDRedmon deleted the feature/GetAlbum branch February 19, 2026 21:08
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.

1 participant