-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Cache remote build map, fetch in registry refresh #3624
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a super sensible improvement! Do we have any tests for this?
From my cursory read, nothing stood out apart from the unused variable. So lgtm!
Log.Debug("Getting cached build map"); | ||
return TrySetBuildMap(File.ReadAllText(cachedBuildMapPath)); | ||
} | ||
catch (Exception e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we doing anything with this exception we're catching? We're getting a few notes about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No; unlike the other TrySet*BuildMap
functions, we don't want to print a warning for this one because we expect it to be missing the first time. I've removed this variable.
9736606
to
1e3c574
Compare
As for tests, I don't know how this could be tested, since it depends on writing to and reading from |
For fun I took the latest build for a spin in my Debian and Fedora VMs with their network devices disabled, and the commands that don't need network access all worked fine. 🎉 |
Problems
My network has been a bit unreliable lately, and I've found that during periods of downtime, not only can I not download mods, but even commands like
ckan instance list
simply hang. (First noticed while working on the Electron UI project previewed in the comments of #2848, which just wraps aroundCKAN.dll
without additional C# code being run.)Cause
When CKAN starts, it loads all the game instances pretty early. To do this, it first has to load the known game versions so it can check each instance's version. Currently we always use the remote build map for this, via an HTTPS request to GitHub. If the network isn't working, it just sits there waiting for timeout.
This isn't a great model. As pointed out in #2108, CKAN should refrain from creating network connections without the user's awareness, especially if it isn't necessary. Furthermore, we already have an embedded build map compiled into CKAN that we essentially never use, because the remote build map is always retrieved first.
An additional quirk is that the command line parameters are handled after all this, so even if you pass
--debug
, thelog.Debug
output of these steps is never printed.Changes
config.json
). If found, we use it, otherwise we fall back to the embedded build map. This eliminates the network call at startup and would allow commands likeckan instance list
to complete while offline.ckan update
and GUI's Refresh button is updated to fetch the remote build map and save a cached copy for future startups, since this represents a time when the user has authorized network activity.--debug
or--verbose
and set the log level if found. This way these arguments can be used to see activity before the full parsing happens, including the build map's initialization.