Commit Graph
124 Commits
Author SHA1 Message Date
Martin Wimpress 30bb8dbb5d fix(downloader): fix resume download corruption and hash verification
- Add proper file seeking to end of file before resuming downloads
- Improve range request logic to only apply when file_size > 0
- Set initial progress bar position for resumed downloads
- Add file.flush() to ensure data is written before hash verification
- Conditionally show download stats only when bytes were downloaded

Fixes regression from v0.1.0 where interrupted downloads would fail hash verification due to corrupted file content when resumed.
2025-05-25 11:57:03 +01:00
Martin Wimpress b8c737ea29 refactor: streamline XML processing pipeline
- Combine XML URL generation and fetching into single function
- Consolidate multi-step XML derivation, validation, and parsing flow
- Reduce intermediate error handling steps for better readability
- Simplify XML metadata processing from discrete steps to unified operation
2025-05-25 11:41:28 +01:00
Martin Wimpress e8db2e1d91 refactor: move signal handling into downloader module
- Relocate signal handler setup from main to downloader module
- Encapsulate signal handling as internal concern of download operations
- Simplify main function by removing signal-related complexity
- Reduce coupling between application initialization and download control
2025-05-25 11:28:27 +01:00
Martin Wimpress 010d20241d refactor: consolidate error handling strategy
- Analyze and merge overlapping error variants (UrlError/NetworkError)
- Standardize error messages and context across modules
- Reduce redundant error types for improved maintainability
- Simplify error propagation patterns throughout codebase
2025-05-25 11:19:52 +01:00
Martin Wimpress cd6b9cdef5 refactor: consolidate constants into dedicated module
- Create new constants.rs module for centralised configuration
- Move USER_AGENT, HTTP_TIMEOUT, and URL_PATTERN from main.rs
- Update imports in main.rs to use constants module
- Add constants module export to lib.rs
2025-05-25 11:09:11 +01:00
Martin Wimpress 22b85cac8d refactor: consolidate constants and simplify URL validation
- Consolidate HTTP timeout constants to single HTTP_TIMEOUT value
- Update tests to compile regex locally for validation
- Remove Unused Imports and Comments
2025-05-25 11:02:57 +01:00
Martin Wimpress 34df5e2fea chore: remove tasks 2025-05-25 10:48:00 +01:00
Martin Wimpress e7078c28a5 refactor(downloader): modularize file download and verification logic
Created a new `downloader` module (`src/downloader.rs`) and moved all functions related to file downloading, content streaming, MD5 hashing, file existence checks, and directory creation from `main.rs` into this new module.

This change includes:
- Moving functions: `download_file`, `download_file_content`, `check_existing_file`, `verify_downloaded_file`, `calculate_md5`, `prepare_file_for_download`, and `ensure_parent_directories`.
- Relocating relevant constants (`BUFFER_SIZE`, `LARGE_FILE_THRESHOLD`) to `downloader.rs`.
- Updating `main.rs` to use `downloader::download_file` and removing the now redundant local functions and associated unused imports.
- Adding `pub mod downloader;` to `lib.rs`.

This refactoring improves code organisation by centralising file operations, enhancing maintainability, and promoting better separation of concerns.
2025-05-25 10:12:50 +01:00
Martin Wimpress 87499a0421 feat(xml): modularize XML data structures into archive_metadata
Refactored XML handling by:
- Moving `XmlFiles` and `XmlFile` struct definitions from `main.rs` to a new `src/archive_metadata.rs` module.
- Updating `main.rs` to import these structures from the new module using `ia_get::archive_metadata`.
2025-05-25 10:00:15 +01:00
Martin Wimpress 7ca16e4121 refactor(core): modularise main application logic and data structures
This commit improves the structure and maintainability of the `ia-get` by extracting general utility functions from `src/main.rs` into a new dedicated `src/utils.rs` module. This centralises common helper functions and slims down `main.rs`.
2025-05-25 01:32:30 +01:00
Martin Wimpress 1fdd8f738b docs: update TASKS 2025-05-25 01:32:30 +01:00
Martin Wimpress 0df5c2c4a0 refactor(constants): extract magic values to named constants
Extract hardcoded values to named constants for better maintainability and readability. This includes:

- BUFFER_SIZE for file operations
- LARGE_FILE_THRESHOLD for progressive hash calculation
- USER_AGENT for HTTP requests
- DEFAULT_HTTP_TIMEOUT for HTTP request timeouts
- URL_CHECK_TIMEOUT for accessibility checks
- SPINNER_TICK_INTERVAL for UI feedback
- PATTERN for URL validation

This change improves code clarity and makes configuration changes easier by centralising magic values in one place.
2025-05-25 00:59:21 +01:00
Martin Wimpress c46e82c456 feat(ui): add animated spinner during initialization
This enhances user experience by providing visual feedback during potentially
slow network operations.

- Add animated braille spinner for feedback during URL processing
- Show progress through URL validation, XML metadata fetching and parsing
- Replace spinner with green tick when processing completes successfully
- Improve error display with appropriate icons for failed operations
- Provide file count summary upon successful initialisation
2025-05-25 00:39:49 +01:00
Martin Wimpress ce778a0d98 feat(ui): add download statistics at completion
- Show download size, duration, and transfer speed when downloads finish
- Add helper functions for formatting sizes, durations, and transfer rates
- Update download_file_content to track and report download statistics
- Use consistent UI elements with existing tree-like structure
2025-05-25 00:19:52 +01:00
Martin Wimpress afe69f6710 refactor(download): extract download logic and optimize URL checks
- Extract file download logic into separate functions
  - download_file: main entry point for file downloads
  - check_existing_file: verify if file exists with correct hash
  - ensure_parent_directories: create directories for downloads
  - prepare_file_for_download: set up file for writing
  - download_file_content: perform the actual download with progress
  - verify_downloaded_file: validate downloaded file hash

- Optimize URL accessibility checking
  - Modify is_url_accessible to accept an existing client
  - Add timeouts to prevent hanging on slow connections
  - Update call sites to reuse the client instance

These changes improve code modularity, maintainability and performance without changing user-facing behaviour.
2025-05-24 23:56:18 +01:00
Martin Wimpress 41d7e83750 refactor(ui): centralize progress bar creation
Implement a factory function for creating progress bars with consistent styling.
2025-05-24 23:32:27 +01:00
Martin Wimpress d4f6e0e906 docs: add tasks 2025-05-23 16:46:14 +01:00
Martin Wimpress 191a85cd39 feat: add graceful signal handling for downloads
- Implement Ctrl+C signal handler with Arc<AtomicBool> for thread-safe state
- Add signal interruption checks in download loops and MD5 calculation
- Preserve download progress when interrupted, allowing seamless resume
- Provide clear user feedback on interruption with resume instructions
- Ensure progress bars are properly cleaned up on signal interruption

This enables users to gracefully cancel long-running downloads while maintaining the ability to resume from where they left off by running the same command again.
2025-05-23 16:38:43 +01:00
Martin Wimpress 564e6f7584 chore: bump version to 0.1.2 2025-05-23 15:46:38 +01:00
Martin Wimpress 1db965ece7 chore: update gitignore 2025-05-23 15:41:57 +01:00
Martin Wimpress 7a1a32287e feat(error): implement structured error handling with thiserror
- Create dedicated error module with custom error types
- Use thiserror for improved error messages and derivation
- Add specific error variants for different failure modes
- Implement From traits for automatic error conversion
- Replace generic error types with custom Result<T>
- Update function signatures for consistent error handling
- Improve error messages for better user feedback

This change follows Rust best practices for error handling and makes debugging easier with more descriptive error messages. It also provides proper error propagation using the ? operator while maintaining type safety throughout the application.
2025-05-23 15:41:11 +01:00
Martin Wimpress e03fbe52b7 ci: generate release notes 2025-05-23 15:18:23 +01:00
Martin Wimpress 92df5de94d refactor: reduces large file threshold for md5 calc
Reduces the threshold for considering a file "large" when calculating its MD5 hash, lowering it from 100MB to 16MB.
2025-05-23 15:11:09 +01:00
dependabot[bot] 1c2ef32e22 chore(deps): bump ring from 0.17.6 to 0.17.14
Bumps [ring](https://github.com/briansmith/ring) from 0.17.6 to 0.17.14.
- [Changelog](https://github.com/briansmith/ring/blob/main/RELEASES.md)
- [Commits](https://github.com/briansmith/ring/commits)

---
updated-dependencies:
- dependency-name: ring
  dependency-version: 0.17.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-05-23 15:07:10 +01:00
Martin Wimpress 233b0ff28b perf(hash): optimize MD5 calculation with streaming approach
This change ensures memory usage remains constant regardless of file size, allowing the application to efficiently verify multi-gigabyte files from Internet Archive without excessive RAM consumption.

- Implement chunked file reading to prevent excessive memory usage
- Add progress bar for large file hash calculation (>100MB)
- Use BufReader with fixed buffer size (8KB) for efficient I/O
- Display visual feedback during hash verification of large files
- Fix memory issue where entire file was loaded into RAM
2025-05-23 14:59:00 +01:00
Martin Wimpress a6369dbe85 docs: Improves unit test documentation
Adds documentation that explains how to run unit tests. Also renames the "Tests" section to "Manual Tests" for clarity.
2025-05-23 14:46:10 +01:00
Martin Wimpress 0e8aabcb1d ci: adds flakehub workflow
Adds a workflow to automatically build and publish the flake to FlakeHub. This allows users to easily discover and use the flake.
2025-05-23 14:19:41 +01:00
Martin Wimpress 04ff21e43a chore: bump version to 0.1.1 2025-05-23 14:16:07 +01:00
Martin Wimpress 1ce3baa3aa chore: updates several dependencies
This includes updating futures, tokio, serde, url
2025-05-23 14:14:27 +01:00
dependabot[bot] 9936188b22 chore(deps): bump reqwest from 0.11.22 to 0.12.15
Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.11.22 to 0.12.15.
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.22...v0.12.15)

---
updated-dependencies:
- dependency-name: reqwest
  dependency-version: 0.12.15
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-05-23 14:03:13 +01:00
Martin Wimpress c51a5e54af fix(xml): correct XML parsing for archive.org metadata format
The issue was introduced when upgrading serde-xml-rs to 0.8.0 which required explicit handling of attributes vs elements in the XML structure.

- Adjust XML parsing to handle nested elements correctly
- Make source attribute optional with proper default handling
- Add safer MD5 hash verification with proper None handling
- Update struct documentation to match actual XML format

Bug: archive.org uses XML attributes for name/source but nested elements for metadata like md5/mtime, causing deserialization failures.
2025-05-23 13:58:40 +01:00
dependabot[bot] c4042edfc4 chore(deps): bump serde-xml-rs from 0.6.0 to 0.8.0
Bumps [serde-xml-rs](https://github.com/RReverser/serde-xml-rs) from 0.6.0 to 0.8.0.
- [Release notes](https://github.com/RReverser/serde-xml-rs/releases)
- [Commits](https://github.com/RReverser/serde-xml-rs/compare/0.6.0...0.8.0)

---
updated-dependencies:
- dependency-name: serde-xml-rs
  dependency-version: 0.8.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-05-23 13:43:58 +01:00
dependabot[bot] cf71ae1a10 chore(deps): bump url from 2.5.0 to 2.5.2
Bumps [url](https://github.com/servo/rust-url) from 2.5.0 to 2.5.2.
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v2.5.0...v2.5.2)

---
updated-dependencies:
- dependency-name: url
  dependency-version: 2.5.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-05-23 13:41:20 +01:00
dependabot[bot] 3a2f972971 chore(deps): bump regex from 1.10.2 to 1.11.1
Bumps [regex](https://github.com/rust-lang/regex) from 1.10.2 to 1.11.1.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.10.2...1.11.1)

---
updated-dependencies:
- dependency-name: regex
  dependency-version: 1.11.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-05-23 13:39:52 +01:00
dependabot[bot] 08c642efb6 chore(deps): bump tokio from 1.33.0 to 1.42.1
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.33.0 to 1.42.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.33.0...tokio-1.42.1)

---
updated-dependencies:
- dependency-name: tokio
  dependency-version: 1.42.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-05-23 13:35:29 +01:00
Martin Wimpress 86f6055909 chore: update dependencies in cargo.lock
Updates dependencies to their latest compatible versions, including clap, anstyle, and windows-sys, ensuring compatibility and potentially incorporating bug fixes and performance improvements from upstream dependencies.

BREAKING CHANGE: cargo.lock version is updated from 3 to 4
2025-05-23 13:33:09 +01:00
Martin WimpressandDaniel Dewberry 4684f18513 feat: modernize code and improve error handling based on community feedback
- Replace old clap builder API with modern derive macros for CLI parsing
- Fix is_url_accessible() to use HEAD requests and proper error propagation
- Add comprehensive documentation comments for all functions and structs
- Add unit tests for URL pattern validation with valid/invalid test cases
- Improve error handling by replacing panic! with proper exit codes
- Set user-agent header to "ia-get" for better internet citizenry
- Update dependencies to use clap 4.0 with derive features

Co-authored-by: Daniel Dewberry <[email protected]>

Implements suggestions from podcast listener feedback received after Linux Matters Episode 20, addressing AI-generated code deficits with proper Rust ecosystem practices and modern idioms.

Close: #7
2025-05-23 13:33:09 +01:00
Martin Wimpress b6532b672d ci: correct typo 2025-05-23 13:06:48 +01:00
Martin Wimpress 5550089614 feat: add more tooling to devshell
Adds useful tools and environment variables to improve the rust development experience within the nix environment. This includes tools like git, gh, nodejs, cargo-watch, cargo-edit, clippy, and rustfmt.

It also configures a shell hook to provide information and sets RUST_BACKTRACE to 1 for easier debugging.
2025-05-23 13:03:11 +01:00
Martin Wimpress d7a8a10e35 chore: add vscode settings
Adds rust-analyzer settings to use clippy and enable all features. Enables github copilot for rust, toml, and markdown files.
2025-05-23 13:03:11 +01:00
Martin Wimpress 619160c9d9 chore: adds crate metadata
Adds categories, description, keywords, repository, and readme to the Cargo.toml. This provides more information about the crate on crates.io and helps with discovery.
2025-05-23 13:03:11 +01:00
Martin Wimpress 171514e30d chore: adds cargo dependabot configuration
Adds a configuration to check for updates to cargo dependencies on a weekly basis.
2025-05-23 13:03:11 +01:00
Martin Wimpress e6eb449311 docs: add copilot instructions 2025-05-23 13:03:11 +01:00
Martin Wimpress 39d2160740 fix(flake): resolve infinite recursion error 2025-05-23 13:03:11 +01:00
Martin Lindhe 62e5bf7cc9 regex: fix escaping and allow . - and @ in identifier, fixes #9 2025-04-15 13:29:20 +01:00
dependabot[bot] b8882c1411 chore(deps): bump softprops/action-gh-release from 1 to 2
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-04-04 13:50:54 +01:00
Martin Wimpress 840461c6d8 docs: update README 2023-12-10 23:33:17 +00:00
Luc Perkins 8031287233 Add package output 2023-12-06 17:00:11 +00:00
Martin Wimpress cc7f884ebd docs: correct the links to Chatty Jeeps reference 2023-12-05 14:24:51 +00:00
Martin Wimpress 9f74ce0e1c docs: update README 2023-12-05 14:09:54 +00:00