fix(font): correct feedback on error

resolves #3782
This commit is contained in:
Jan De Dobbeleer 2023-05-02 17:27:36 +02:00 committed by Jan De Dobbeleer
parent 96b3f01ae7
commit cef5def472
2 changed files with 6 additions and 6 deletions

View file

@ -139,11 +139,11 @@ func (m *main) Init() tea.Cmd {
return tea.Quit
}
isZipFile := func() bool {
return strings.HasSuffix(m.font, ".zip")
isLocalZipFile := func() bool {
return !strings.HasPrefix(m.font, "https") && strings.HasSuffix(m.font, ".zip")
}
if len(m.font) != 0 && !isZipFile() {
if len(m.font) != 0 && !isLocalZipFile() {
m.state = downloadFont
if !strings.HasPrefix(m.font, "https") {
m.font = fmt.Sprintf("https://github.com/ryanoasis/nerd-fonts/releases/latest/download/%s.zip", m.font)
@ -156,7 +156,7 @@ func (m *main) Init() tea.Cmd {
}
defer func() {
if isZipFile() {
if isLocalZipFile() {
go installLocalFontZIP(m.font)
return
}
@ -167,7 +167,7 @@ func (m *main) Init() tea.Cmd {
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("170"))
m.spinner = s
m.state = getFonts
if isZipFile() {
if isLocalZipFile() {
m.state = unzipFont
}
return m.spinner.Tick

View file

@ -58,7 +58,7 @@ func getRemoteFile(location string) (data []byte, err error) {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return
return data, fmt.Errorf("Failed to download zip file: %s\n→ %s", resp.Status, location)
}
data, err = io.ReadAll(resp.Body)