Skip to content

Fixed mod updates not fetching correct URL - #105

Merged
thesupersonic16 merged 1 commit into
hedge-dev:mainfrom
dreamsyntax:fix-mod-updates
Oct 19, 2025
Merged

Fixed mod updates not fetching correct URL#105
thesupersonic16 merged 1 commit into
hedge-dev:mainfrom
dreamsyntax:fix-mod-updates

Conversation

@dreamsyntax

@dreamsyntax dreamsyntax commented Oct 12, 2025

Copy link
Copy Markdown
Contributor

Resolves #104

Tested on both Windows and Linux

  • Verified Gamebanana updates work as expected
  • Verified GitHub updates work as expected

Note: This PR only fixes the broken update functionality. The 'check on startup' is still broken and is unrelated to this PR.

@thesupersonic16

Copy link
Copy Markdown
Member

UpdateSourceGMI uses UpdateServer from mod.ini as the client's BaseAddress which expects the URL to end with a forward slash. You can see the issue you are having in the remarks section which matches with what you found in the linked issue.

Note that all characters after the right-most "/" in the base URI are excluded when combined with the message URI.

I am thinking a better solution could be removing the use of BaseAddress from the HttpClient by replacing it with a combine function such as Helpers.CombineURL(Uri, string)

As for the "Check for mod updates" option, there is no implementation to display the updates yet, so it isn't called.

@dreamsyntax

dreamsyntax commented Oct 17, 2025

Copy link
Copy Markdown
Contributor Author

I am thinking a better solution could be removing the use of BaseAddress from the HttpClient by replacing it with a combine function such as Helpers.CombineURL(Uri, string)

Sure, I will change to this and test.

Update:
Verified with new build on linux and windows going from the same source mod 0.4.4 to 1.0.0

@dreamsyntax

Copy link
Copy Markdown
Contributor Author

Removing the use of BaseAddress

I changed to use the helper for cleaner implementation.
That said, does it make more sense to just updated the updateSource itself, maybe in the constructor?

ex for:

    public UpdateSourceHMM(IMod mod, Uri baseURI)
    {
        BaseURI = baseURI;
        Mod = mod;
    }
    public UpdateSourceHMM(IMod mod, Uri baseURI)
    {
-      BaseURI = baseURI;
+     BaseURI = Helpers.EnsureEndsInSlash(baseURI); // would add `/` if not in mod ini (most mods dont have it), and do nothing otherwise
        Mod = mod;
    }

@thesupersonic16

thesupersonic16 commented Oct 18, 2025

Copy link
Copy Markdown
Member

I don't think UpdateSourceHMM needs touching as that uses a different method of handling URL paths, althrough untested in your case.

Another solution could be just adding .TrimEnd('/') + '/' in ModGeneric to ensure all paths end with a slash to signify a base path which UpdateServer is meant to be, and this way UpdateSourceMulti will always get a path that is a directory which requires no other changes.

            var server = mainSection.Get("UpdateServer", string.Empty);
-           if (Uri.TryCreate(server, UriKind.Absolute, out Uri? uri))
+           if (Uri.TryCreate(server.TrimEnd('/') + '/', UriKind.Absolute, out Uri? uri))
            {
                Updater = new UpdateSourceMulti(this, uri);
            }

Edit: You can also make that into a function in the helper class if you think this looks too confusing, simlar code is used in that class aswell.

@dreamsyntax

Copy link
Copy Markdown
Contributor Author

I don't think UpdateSourceHMM needs touching as that uses a different method of handling URL paths, althrough untested in your case.

Correct, in the above I mistakenly referenced the wrong file. Per the actual changes it would be in GMI.

I think I like the ModGeneric solution personally. I'll change to that and test.

@dreamsyntax

Copy link
Copy Markdown
Contributor Author

ModGeneric solution works as expected 👍
I prefer it, if it looks good to you.

@thesupersonic16 thesupersonic16 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Aside from the function name, I think this PR looks good. Please change the name to something that is less mis-leading to those who don't check the function description.

Comment thread Source/HedgeModManager/Helpers.cs Outdated
@thesupersonic16
thesupersonic16 merged commit cac00b3 into hedge-dev:main Oct 19, 2025
@dreamsyntax
dreamsyntax deleted the fix-mod-updates branch October 19, 2025 15:36
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.

Mod Update / Changelog Fetches wrong URL for GitHub source

2 participants