mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 13:20:42 +00:00
63 lines
2.1 KiB
Markdown
63 lines
2.1 KiB
Markdown
|
|
# pub.p5i File Implementation
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
This document describes the implementation of the pub.p5i file creation feature for backward compatibility with older IPS versions. The pub.p5i file is created for each publisher in the repository and contains basic information about the publisher.
|
||
|
|
|
||
|
|
## File Format
|
||
|
|
|
||
|
|
The pub.p5i file is a JSON file with the following structure:
|
||
|
|
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"packages": [],
|
||
|
|
"publishers": [
|
||
|
|
{
|
||
|
|
"alias": null,
|
||
|
|
"name": "publisher_name",
|
||
|
|
"packages": [],
|
||
|
|
"repositories": []
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"version": 1
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
## Implementation Details
|
||
|
|
|
||
|
|
The pub.p5i file is created in two scenarios:
|
||
|
|
|
||
|
|
1. When a publisher is added to the repository individually using the `add_publisher` method
|
||
|
|
2. At the end of a transaction that includes a new publisher
|
||
|
|
|
||
|
|
### Changes Made
|
||
|
|
|
||
|
|
1. Added a `create_pub_p5i_file` method to the `FileBackend` implementation:
|
||
|
|
- This method creates the pub.p5i file with the correct structure
|
||
|
|
- It uses serde to serialize the data to JSON
|
||
|
|
|
||
|
|
2. Modified the `add_publisher` method to create the pub.p5i file:
|
||
|
|
- Creates the publisher directory if it doesn't exist
|
||
|
|
- Calls the `create_pub_p5i_file` method to create the pub.p5i file
|
||
|
|
|
||
|
|
3. Modified the `Transaction::commit` method to check if a pub.p5i file needs to be created:
|
||
|
|
- Checks if the publisher directory exists but the pub.p5i file doesn't
|
||
|
|
- Creates the pub.p5i file if needed
|
||
|
|
|
||
|
|
4. Added tests to verify the pub.p5i file creation:
|
||
|
|
- Modified `test_add_publisher` to check for the pub.p5i file
|
||
|
|
- Added a new test `test_transaction_pub_p5i_creation` to verify pub.p5i creation during a transaction
|
||
|
|
|
||
|
|
## Testing
|
||
|
|
|
||
|
|
The implementation has been tested with the following scenarios:
|
||
|
|
|
||
|
|
1. Adding a publisher directly using the `add_publisher` method
|
||
|
|
2. Adding a publisher through a transaction
|
||
|
|
|
||
|
|
Both scenarios correctly create the pub.p5i file with the expected structure.
|
||
|
|
|
||
|
|
## Future Considerations
|
||
|
|
|
||
|
|
- The current implementation creates a minimal pub.p5i file with empty arrays for packages and repositories
|
||
|
|
- In the future, we might want to populate these arrays with actual data if needed for backward compatibility
|