Skip to content

IrakliLomidze/Codex365V2Downloader

Repository files navigation

Codex365 Downloader

A professional C# (.NET 8+) Azure Blob Storage downloader application with advanced features for reliable large file downloads.

Features

Core Functionality

  • Azure Blob Storage Integration: Full support for Azure Blob Storage with multiple authentication methods
  • Chunked Downloads: Configurable chunk size (default: 4MB) for efficient large file handling
  • Parallel Processing: Concurrent chunk downloads using ThreadPool and Task Parallel Library
  • Pausable/Resumable: Downloads can be paused and resumed at any time
  • State Persistence: SQLite database tracks download progress and enables recovery after application restart

Reliability & Resilience

  • Retry Logic: Exponential backoff retry policy for failed chunks using Polly
  • Circuit Breaker: Network instability protection with configurable failure thresholds
  • Checksum Validation: MD5 checksum verification for downloaded chunks and complete files
  • Error Handling: Comprehensive error handling and logging
  • Concurrent Access: Thread-safe state management for multiple simultaneous downloads

Authentication Support

  • Connection String: Traditional Azure Storage connection string authentication
  • Managed Identity: Azure Active Directory Managed Identity support for secure, credential-free authentication
  • DefaultAzureCredential: Automatic credential discovery in Azure environments
  • Public Blob Access: Direct HTTPS URLs for publicly accessible blobs (no authentication required)

User Interface

  • Interactive Console: Rich console interface using Spectre.Console
  • WPF GUI Application: Cross-platform graphical interface with Fluent UI design and dark theme support
  • Multi-language Support: English and Georgian language support with easy language switching
  • Real-time Progress: Live progress reporting with download speed and ETA
  • Multiple Downloads: Manage multiple concurrent downloads
  • Download Management: Start, pause, resume, cancel, and monitor downloads

Configuration

Authentication Methods

Connection String (Development/Testing)

{
  "ConnectionStrings": {
    "AzureStorage": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net"
  }
}

Managed Identity (Production)

{
  "AzureStorage": {
    "AccountUrl": "https://mystorageaccount.blob.core.windows.net"
  }
}

Public Blob Access (No Authentication)

For publicly accessible blobs, leave both ConnectionStrings:AzureStorage and AzureStorage:AccountUrl empty or unset:

{
  "ConnectionStrings": {
    "AzureStorage": ""
  },
  "AzureStorage": {
    "AccountUrl": ""
  }
}

Then use direct HTTPS URLs like:

  • https://mystorageaccount.blob.core.windows.net/public-container/file.zip
  • https://mydomain.com/files/document.pdf (if using custom domain)

Download Configuration

{
  "DownloadConfiguration": {
    "ChunkSizeBytes": 4194304,           // 4MB chunks
    "MaxParallelDownloads": 4,           // Maximum concurrent downloads
    "MaxRetryAttempts": 3,               // Retry attempts per chunk
    "RetryDelay": "00:00:01",            // Base retry delay
    "CircuitBreakerTimeout": "00:05:00", // Circuit breaker timeout
    "CircuitBreakerFailureThreshold": 5, // Failures before opening circuit
    "DatabasePath": "downloads.db"       // SQLite database path
  }
}

Usage

Console Application

dotnet run --project src/Codex365Downloader.Console

WPF GUI Application

dotnet run --project src/Codex365Downloader.WPF

The WPF GUI provides a user-friendly graphical interface with:

  • Modern Fluent UI design
  • Real-time progress bars and statistics
  • File browser for easy location selection
  • Concurrent download management
  • Cross-platform support (Windows, macOS, Linux)

See WPF GUI README for detailed usage instructions.

Download Management

  1. Start New Download: Enter blob URL and local file path
  2. View Downloads: See all downloads with status and progress
  3. Pause Download: Temporarily halt an active download
  4. Resume Download: Continue a paused download from where it left off
  5. Cancel Download: Stop and remove a download

Environment Variables

Set configuration via environment variables:

export ConnectionStrings__AzureStorage="your-connection-string"
export AzureStorage__AccountUrl="https://youraccount.blob.core.windows.net"
export DownloadConfiguration__ChunkSizeBytes=8388608

Architecture

Project Structure

src/
├── Codex365Downloader.Core/         # Core business logic
│   ├── Models/                      # Data models
│   ├── Interfaces/                  # Service interfaces
│   ├── Services/                    # Core services
│   ├── Data/                        # Data access layer
│   └── Extensions/                  # Dependency injection extensions
├── Codex365Downloader.Console/      # Console application
├── Codex365Downloader.WPF/          # WPF GUI application
│   ├── ViewModels/                  # MVVM ViewModels
│   ├── Views/                       # XAML Views
│   └── README.md                    # GUI-specific documentation
└── tests/
    └── Codex365Downloader.Tests/    # Unit and integration tests

Key Components

DownloadService

Main orchestrator for download operations:

  • Manages download lifecycle
  • Coordinates chunked downloads
  • Handles parallel processing
  • Implements retry logic

BlobStorageService

Azure Blob Storage integration:

  • Blob size retrieval
  • Chunk-based downloads
  • Connection string and Managed Identity support

SqliteStateRepository

Persistent state management:

  • Download metadata storage
  • Chunk completion tracking
  • Recovery support

CircuitBreaker

Network resilience:

  • Failure threshold monitoring
  • Automatic circuit opening/closing
  • Protection against cascading failures

Testing

Run Unit Tests

dotnet test

Test Coverage

  • Core download logic validation
  • State persistence verification
  • Circuit breaker functionality
  • Checksum calculation accuracy

Dependencies

Core Dependencies

  • Azure.Storage.Blobs: Azure Blob Storage client
  • Azure.Identity: Azure authentication
  • Microsoft.Data.Sqlite: SQLite data access
  • Polly: Resilience and retry patterns
  • Spectre.Console: Rich console interface

GUI Dependencies

  • Avalonia: Cross-platform .NET UI framework
  • CommunityToolkit.Mvvm: MVVM helpers and source generators

Development Dependencies

  • xUnit: Testing framework
  • Moq: Mocking framework

Performance Considerations

Large File Support

  • Optimized for files >1GB
  • Memory-efficient streaming
  • Configurable chunk sizes
  • Parallel processing

Network Optimization

  • Concurrent chunk downloads
  • Retry logic for network failures
  • Circuit breaker for stability
  • Progress reporting without blocking

Resource Management

  • Proper disposal of streams and connections
  • Semaphore-controlled concurrency
  • Memory-efficient chunk processing

Security

Credential Management

  • No hardcoded credentials
  • Managed Identity support
  • Secure credential storage
  • Environment variable configuration

Data Integrity

  • MD5 checksum validation
  • Chunk-level verification
  • File integrity checks
  • Error detection and recovery

Deployment

Azure VM/Container

# Install .NET 8 Runtime
# Configure Managed Identity
# Set environment variables
dotnet Codex365Downloader.Console.dll

Docker

FROM mcr.microsoft.com/dotnet/runtime:8.0
COPY . /app
WORKDIR /app
ENTRYPOINT ["dotnet", "Codex365Downloader.Console.dll"]

Localization

The WPF GUI application supports multiple languages:

  • English (en): Default language
  • Georgian (ka): ქართული ენა

Using Different Languages

  • Use the language selector in the top-right corner of the application
  • Changes take effect immediately without restarting

Adding New Languages

See Localization Guide for detailed instructions on:

  • Adding new language support
  • Translating UI strings
  • Testing localization

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For questions, issues, or feature requests, please open an issue on GitHub.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors