Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify F-Droid Repository Bridge json retrieval #4062

Closed
Mynacol opened this issue Apr 5, 2024 · 1 comment · Fixed by #4063
Closed

Simplify F-Droid Repository Bridge json retrieval #4062

Mynacol opened this issue Apr 5, 2024 · 1 comment · Fixed by #4063
Labels
Bridge-Feature-Request Request for a new bridge feature

Comments

@Mynacol
Copy link
Contributor

Mynacol commented Apr 5, 2024

#4056 led me to look into the FDroidRepoBridge. It currently fetches a index-v1.jar file and saves it temporarily to unzip the containing json. We can improve that and simplify the code by getting the json directly.

I looked into avoiding the writing-to-file and then reading-from-file altogether. Using a special file path that leaves the data in memory probably wouldn't work. But I'm confused why we use the index-v1.jar file altogether?
The main F-Droid repo lists not only index-v1.jar (which only makes sense if we were to use the contained signature, which we don't), but also index-v1.json and index-v2.json. These json files can be fetched with getContents, optionally cached, and directly fed into Json::decode without using a temporary file. The HTTP transfer encoding can compress the file to a similar degree the jar (=zip) can.

Now the question is whether all the F-Droid repositories out there have this file. I went through the whole list of known repositories and only one repo misses the index-v1.json file: Bromite. Under these circumstances we can depend on the availability of the index-v1.json file.

@dvikan Do you agree? Then just merge the referenced PR :)

@Mynacol Mynacol added the Bridge-Feature-Request Request for a new bridge feature label Apr 5, 2024
Mynacol added a commit to Mynacol/rss-bridge that referenced this issue Apr 5, 2024
I looked into avoiding the writing-to-file and then reading-from-file altogether. Using a special file path that leaves the data in memory probably wouldn't work. But I'm unsure why we use the `index-v1.jar` file altogether.
The main F-Droid repo [lists](https://f-droid.org/en/docs/All_our_APIs/#the-repo-index) not only `index-v1.jar` (which only makes sense if we were to use the contained signature, which we don't), but also `index-v1.json` and `index-v2.json`. These json files can be fetched with `getContents`, optionally cached, and directly fed into `Json::decode` without using a temporary file. The HTTP transfer encoding can compress the file to a similar degree the jar (=zip) can. That's exactly what this commit uses.

Now the question is whether all the F-Droid repositories out there have this file. I went through the whole [list of known repositories](https://forum.f-droid.org/t/known-repositories/721) and only one repo misses the `index-v1.json` file: [Bromite](https://fdroid.bromite.org/fdroid/repo/index-v1.json). Under these circumstances we can depend on the availability of the `index-v1.json` file.

Closes RSS-Bridge#4062
dvikan pushed a commit that referenced this issue Apr 5, 2024
* [FDroidRepoBridge] Simplify json retrieval

I looked into avoiding the writing-to-file and then reading-from-file altogether. Using a special file path that leaves the data in memory probably wouldn't work. But I'm unsure why we use the `index-v1.jar` file altogether.
The main F-Droid repo [lists](https://f-droid.org/en/docs/All_our_APIs/#the-repo-index) not only `index-v1.jar` (which only makes sense if we were to use the contained signature, which we don't), but also `index-v1.json` and `index-v2.json`. These json files can be fetched with `getContents`, optionally cached, and directly fed into `Json::decode` without using a temporary file. The HTTP transfer encoding can compress the file to a similar degree the jar (=zip) can. That's exactly what this commit uses.

Now the question is whether all the F-Droid repositories out there have this file. I went through the whole [list of known repositories](https://forum.f-droid.org/t/known-repositories/721) and only one repo misses the `index-v1.json` file: [Bromite](https://fdroid.bromite.org/fdroid/repo/index-v1.json). Under these circumstances we can depend on the availability of the `index-v1.json` file.

Closes #4062

* [FDroidRepoBridge] Cleanup not requiring Zip

With the last commit 1152386, the zip
extension is not required anymore. Don't fail if it's not available.
@dvikan
Copy link
Contributor

dvikan commented Apr 5, 2024

The original reasononung for using a temp file for the zip file was to avoid memory limit issues.

If json file is already present in the url then all is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bridge-Feature-Request Request for a new bridge feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants