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

Support alternative Thunderstore CDN #1130

Merged
merged 8 commits into from
Dec 19, 2023
Merged

Conversation

anttimaki
Copy link
Collaborator

No description provided.

@anttimaki anttimaki changed the base branch from master to develop December 14, 2023 14:00
@anttimaki
Copy link
Collaborator Author

anttimaki commented Dec 14, 2023

Known issues:

  1. I tested this by manipulating the hosts file of Windows. Despite my best efforts it seems the health test requests get cached sometimes. IDK but I think it happens on OS/hardware level since it seems to sometimes happen on regular browser too.

  2. Seems the error logging in UtilityMixin breaks on TSMM because it claims the logging provider is not initiated. The logging is done on UtilityMixin in the hopes of avoiding code duplication between the projects. Maybe I need to move where things are done around a bit, but the logic itself shouldn't change, so this is good to review I think.

Related TS PR: thunderstore-io/Thunderstore#960

Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than a boolean toggle state, are you able to structure this so it has N potential options, and the exact one which should be used is passed to the code which needs to consume it?

@anttimaki
Copy link
Collaborator Author

Rather than a boolean toggle state, are you able to structure this so it has N potential options, and the exact one which should be used is passed to the code which needs to consume it?

Made it so.

Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The startup time blocking is a real concern, but in general this looks good to me.

Pre-approving

src/r2mm/downloading/BetterThunderstoreDownloader.ts Outdated Show resolved Hide resolved
src/utils/CdnUtils.ts Outdated Show resolved Hide resolved
src/utils/CdnUtils.ts Outdated Show resolved Hide resolved
The implementation is "backported" from Thunderstore Mod Manager since
it's now needed in r2mm too.

Refs TS-2003
A class containing static methods intended to provide support for
multiple Thunderstore CDNs:

- Check connection to CDNs and remember which one works
- Provide a method for replacing the CDN host from URLs. This can be
  used when the mod manager uses the URL directly.
- Provide a method for augmenting an URL with a query parameter
  denoting the preferred CDN. This can be used when download happens
  via a redirect from Thunderstore API, although it requires that the
  API endpoint has been set up to deal with the query parameter.

Refs TS-2003
This is required so that also the UtilityMixin can show the error modal
in the future.

Refs TS-2003
A list of predefined CDNs are tested, and the first one that is reached
will be stored internally by CdnProvider as the preferred one. Other
parts of the code that deal with CDNs can use the static helper methods
provided by the class.

If no CDN can be reached, an error modal is shown to the user about the
issue. Hopefully the provided suggestion will help some users.

Refs TS-2003
Since the icon URLs for non-installed packages are read from the
PackageVersion metadata and downloaded by the browser, brute force
replacement of the domain is required.

Refs TS-2003
Since the actual download URL is returned by the Thunderstore API as a
redirect, signal the API with a query parameter that an alternative CDN
is preferred.

Refs TS-2003
Since the actual download URL is returned by the Thunderstore API as a
redirect, signal the API with a query parameter that an alternative CDN
is preferred.

Refs TS-2003
Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

src/utils/HttpUtils.ts Show resolved Hide resolved
@anttimaki anttimaki merged commit 483e533 into develop Dec 19, 2023
4 checks passed
@anttimaki anttimaki deleted the support-alternative-cdn branch December 19, 2023 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants