Commit Graph
142 Commits
Author SHA1 Message Date
dependabot[bot] 04014886ea chore(deps): bump clap from 4.5.39 to 4.5.40
Bumps [clap](https://github.com/clap-rs/clap) from 4.5.39 to 4.5.40.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.39...clap_complete-v4.5.40)

---
updated-dependencies:
- dependency-name: clap
  dependency-version: 4.5.40
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-06-10 06:15:27 +01:00
dependabot[bot] e34c77ddcb chore(deps): bump serde-xml-rs from 0.8.0 to 0.8.1
Bumps [serde-xml-rs](https://github.com/RReverser/serde-xml-rs) from 0.8.0 to 0.8.1.
- [Release notes](https://github.com/RReverser/serde-xml-rs/releases)
- [Commits](https://github.com/RReverser/serde-xml-rs/compare/0.8.0...0.8.1)

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

Signed-off-by: dependabot[bot] <[email protected]>
2025-06-03 10:33:24 +01:00
dependabot[bot] 45de4e2f70 chore(deps): bump clap from 4.5.38 to 4.5.39
Bumps [clap](https://github.com/clap-rs/clap) from 4.5.38 to 4.5.39.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.38...clap_complete-v4.5.39)

---
updated-dependencies:
- dependency-name: clap
  dependency-version: 4.5.39
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-06-03 10:33:01 +01:00
dependabot[bot] 5d99754f24 chore(deps): bump reqwest from 0.12.15 to 0.12.19
Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.12.15 to 0.12.19.
- [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.12.15...v0.12.19)

---
updated-dependencies:
- dependency-name: reqwest
  dependency-version: 0.12.19
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-06-03 10:32:42 +01:00
Martin Wimpress 6e66b5a02e fix(ci): fix the release workflow 2025-05-26 00:04:05 +01:00
Martin Wimpress 0e0ae8ba33 docs: update README.md 2025-05-25 23:56:52 +01:00
Martin Wimpress 8cee3c672d docs: add new demo 2025-05-25 23:42:37 +01:00
Martin Wimpress 9522c164cd chore: update dependencies
- Upgrade dependencies to their latest versions
2025-05-25 22:59:59 +01:00
Martin Wimpress 7ea122d5bb ui: replace emoji with coloured unicode symbols/glyphs
This commit enhances the user interface by adding coloured glyphs/symbols instead of emoji.

- Added the coloured crate as a dependency.
- Modified downloader.rs to incorporate coloured output for download status, MD5 hashing, and error messages.
- Updated main.rs to use colours in spinner messages and validation feedback.
- Modified utils.rs to format progress bar messages with colours.
- Reduced the LARGE_FILE_THRESHOLD in downloader.rs from 16MB to 2MB, to trigger hashing progress bar more frequently.
2025-05-25 17:22:39 +01:00
Martin Wimpress 404032b8c0 docs: safe unwrap in URL processing
- Adds a comment explaining why the unwrap operation on the URL identifier is considered safe.
- Clarifies that the URL is validated before this operation, ensuring a valid identifier segment exists.
2025-05-25 14:44:50 +01:00
Martin Wimpress 93ca050292 fix: correct misleading error message
- Improves error message clarity for XML parsing failures.
- Specifies that the error occurs during parsing of _files.xml.
2025-05-25 14:44:50 +01:00
Martin Wimpress 3bc46f8f9d refactor: improve archive.org URL validation
- Improves archive.org URL validation to ensure the identifier after "/details/" is not empty.
- Updates error message for invalid URLs to provide a more descriptive explanation of the expected format.
- Streamlines error handling in the main function by directly displaying the error message from the validation function.
2025-05-25 14:44:50 +01:00
Martin Wimpress d7211b3dab refactor: renames error variant for XML parsing
- Updates the name of an error variant for better clarity
- Removes a redundant error variant
2025-05-25 14:44:50 +01:00
Martin Wimpress 033254ce2b ui: enhance download progress information with a counter
Adds a counter to the download progress display.

*   Displays the current file number and the total number of files being downloaded.
2025-05-25 13:55:02 +01:00
Martin Wimpress a7af6f5c85 refactor(main): centralise exit logic by returning Result
Removes direct calls to `std::process::exit` from `fetch_xml_metadata` and error handling blocks within `main`. These functions now propagate errors by returning `Result`.

This change improves testability and aligns with idiomatic Rust error handling, allowing `main` to be the single point of exit for the application on error. Spinner messages for context are retained.
2025-05-25 13:23:29 +01:00
Martin Wimpress 8c739b0da3 fix(url): correctly handle trailing slashes in get_xml_url and update tests
The `get_xml_url` function has been updated to ensure consistent identifier extraction from archive.org details URLs, regardless of the presence of a trailing slash. This is achieved by trimming any trailing slash before splitting the URL to find the identifier.

The corresponding unit tests in `check_get_xml_url` have been revised to accurately reflect and verify this behavior, covering cases with and without trailing slashes for various URL patterns. This ensures the correct formation of the XML metadata URL.
2025-05-25 13:23:29 +01:00
Martin Wimpress 9a041a859a refactor: consolidate URL validation and extract constants
- Move URL validation to utils.rs with lazy static regex compilation
- Extract XML_DEBUG_TRUNCATE_LEN constant to constants.rs
- Centralise URL pattern validation logic to eliminate duplication
2025-05-25 13:23:29 +01:00
Martin Wimpress a8cac0cde7 style: make ui consistent 2025-05-25 12:18:35 +01:00
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