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

Repo update usability fixes #3249

Merged
merged 1 commit into from
Jan 9, 2021
Merged

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Dec 22, 2020

Background / motivation

After KSP-CKAN/CKAN-meta#2159, many users opted in to the Kopernicus Bleeding Edge repo to use Kopernicus on recent game versions.

This PR attempts to modernize repo updates somewhat.

Problems

  • In the last few days, @R-T-B's server went down and those users saw errors:
    screenshot
    • The stack trace is big and scary and doesn't help users
    • There's no obvious way back to the normal app screens. Cancel is available but does nothing; if you're extremely clever, clicking the Manage mods tab works.
    • There's not a lot of info shown about what's going on during a repo update
  • CmdLine's IUser implementation always prints \r\n before RaiseProgress and after RaiseMessage (implicitly via WriteLine). This means that if you alternate them, you end up with separate messages combined onto one line or extra blank lines. The existing code has a number of workarounds in place due to this.
  • For the last few releases, we've been getting reports of registry corruption at upgrade, where CKAN/registry.json is truncated and can no longer be loaded. I had this happen once myself far too long ago to be able to investigate it (and probably not related to updating CKAN).

Changes

Core:

  • Now the repo update code uses IUser.RaiseProgress to announce the start of each step it performs and IUser.RaiseMessage to announce the completion of each step it performs. This way, you can look at the progress bar to see what CKAN is doing right now and the text box to see what has already been finished.
    • 0%–10% - Querying the ETags to see if we need to update at all
    • 10%–90% - Updating each repo, with the percentages split up evenly across this range
    • 90%–100% - Saving the registry
  • Now the repo update code calls IUser.RaiseError instead of IUser.RaiseMessage when there's a download error, and it uses Exception.Message instead of Exception.ToString() to omit the stack trace
  • Now registry saves are done in a transaction, so truncated files should be a thing of the past, as if anything goes wrong the old file will be preserved

CmdLine:

  • Now ConsoleUser internally tracks whether its last output left the cursor at the start of the line or not. This allows it to alternate RaiseProgress and RaiseMessage calls with no missing or extra line breaks. This makes the above Core changes look right for ckan update.
  • Now ckan update no longer prints a message at the start, because the Core code will take care of that

ConsoleUI:

  • Now updating the repo jumps the user to a progress bar screen that displays the above messages and errors and progress bar updates from Core. Previously it was just a non-interactive dialog box that went away when the update finished.
    (I'm kind of proud how easy it was to do this, just a few lines to add a whole new screen flow.)

GUI:

  • Now if a repo update fails, the changes to Core will announce them with an error popup that doesn't have a stack trace. Once the user closes the error, GUI switches back to the mod list and hides the progress bar tab.

@HebaruSan HebaruSan added Bug Something is not working as intended Enhancement New features or functionality GUI Issues affecting the interactive GUI Cmdline Issues affecting the command line Core (ckan.dll) Issues affecting the core part of CKAN Pull request Network Issues affecting internet connections of CKAN ConsoleUI Issues affecting the interactive console UI labels Dec 22, 2020
@HebaruSan HebaruSan requested a review from DasSkelett December 22, 2020 23:41
@HebaruSan HebaruSan force-pushed the fix/repo-updating branch 3 times, most recently from 2e01d14 to c988406 Compare January 8, 2021 16:58
Copy link
Member

@DasSkelett DasSkelett 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. Let's give this a try, maybe we can prevent some broken registries.

@HebaruSan HebaruSan merged commit dd3e0ce into KSP-CKAN:master Jan 9, 2021
@HebaruSan HebaruSan deleted the fix/repo-updating branch January 9, 2021 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Cmdline Issues affecting the command line ConsoleUI Issues affecting the interactive console UI Core (ckan.dll) Issues affecting the core part of CKAN Enhancement New features or functionality GUI Issues affecting the interactive GUI Network Issues affecting internet connections of CKAN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants