MCPcopy Create free account
hub / github.com/FlashpointProject/FlashpointUltimateUpdater / loadDatabaseResume

Function loadDatabaseResume

main.go:700–772  ·  view source on GitHub ↗
(p string, resumable bool, state *InstallerState)

Source from the content-addressed store, hash-verified

698}
699
700func loadDatabaseResume(p string, resumable bool, state *InstallerState) {
701 fmt.Printf("chosen: %v\n", p)
702
703 err := state.folderPath.Set(p)
704 if err != nil {
705 panic(err)
706 }
707 if resumable {
708 // Cover with a dialog since this can take a while!
709 openWaitScreen("Loading Install State...", state.window)
710 defer func() {
711 state.window.SetContent(setupLayout(state.window, state))
712 }()
713 repo, err := OpenDatabase(filepath.Join(p, "ultimate.sqlite"))
714 if err != nil {
715 dialog.NewError(&BrokenResumableState{err}, state.window).Show()
716 return
717 }
718 overview, err := repo.GetOverview()
719 if err != nil {
720 dialog.NewError(&BrokenResumableState{err}, state.window).Show()
721 return
722 }
723 totalDownloadedSize, err := repo.GetTotalDownloadedSize()
724 if err != nil {
725 dialog.NewError(&BrokenResumableState{err}, state.window).Show()
726 return
727 }
728 totalDownloadedFiles, err := repo.GetTotalDownladedFiles()
729 if err != nil {
730 dialog.NewError(&BrokenResumableState{err}, state.window).Show()
731 return
732 }
733 _ = state.installName.Set(overview.Name)
734 state.totalFiles = overview.TotalFiles
735 state.totalSize = overview.TotalSize
736 state.downloadedFiles = totalDownloadedFiles
737 state.downloadedSize = totalDownloadedSize
738 state.baseUrl = overview.BaseUrl
739 _ = state.formatDownloadedFiles.Set(humanize.Comma(state.downloadedFiles))
740 _ = state.formatDownloadedSize.Set(FormatBytes(state.downloadedSize))
741 _ = state.formatTotalFiles.Set(humanize.Comma(state.totalFiles))
742 _ = state.formatTotalSize.Set(FormatBytes(state.totalSize))
743 progress := float64(state.downloadedSize) / float64(state.totalSize) * 100
744 err = state.progressBarTotal.Set(progress)
745 if err != nil {
746 dialog.NewError(err, state.window).Show()
747 }
748 state.Repo = repo
749 state.resumable = false
750 for _, v := range state.Meta.Available {
751 if v == overview.Name {
752 state.resumable = true
753 }
754 }
755 if !state.resumable {
756 dialog.NewError(&VersionTooOld{}, state.window).Show()
757 }

Callers 2

NewInstallStateFunction · 0.85
setupLayoutFunction · 0.85

Calls 8

openWaitScreenFunction · 0.85
setupLayoutFunction · 0.85
OpenDatabaseFunction · 0.85
FormatBytesFunction · 0.85
GetOverviewMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected