Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
royroyee committed Feb 19, 2024
1 parent 55006d8 commit 5551263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ func (ac *AlpaconClient) sendRequest(req *http.Request) ([]byte, error) {
}
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

if req.Method == "POST" && (resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusOK) {
return nil, fmt.Errorf("POST request failed: %s (%s)", resp.Status, string(body))
return nil, errors.New(resp.Status + string(respBody))
} else if req.Method == "DELETE" && resp.StatusCode != http.StatusNoContent {
return nil, fmt.Errorf("DELETE request failed: %s (%s)", resp.Status, string(body))
return nil, errors.New(resp.Status + string(respBody))
} else if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
return nil, fmt.Errorf("unexpected status code: %s (%s)", resp.Status, string(body))
return nil, errors.New(resp.Status + string(respBody))
}

return body, nil
return respBody, nil
}

// Get Request to Alpacon Server
Expand Down
4 changes: 2 additions & 2 deletions cmd/ftp/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ func downloadFile(client *client.AlpaconClient, src string, dest string) {
utils.CliError("Failed to download the file from server: %s", err)
return
}
utils.CliInfo("`%s` successfully downloaded from server `%s`", src, dest)
utils.CliInfo("Download request for %s to server %s successful. Verify in events (alpacon events).", src, dest)
}

func uploadFile(client *client.AlpaconClient, src []string, dest string) {
err := ftp.UploadFile(client, src, dest)
if err != nil {
utils.CliError("Failed to upload the file to server %s", err)
}
utils.CliInfo("`%s` successfully uploaded to `%s` ", src, dest)
utils.CliInfo("Upload request for %s to %s successful. Verify in events (alpacon events).", src, dest)
}

0 comments on commit 5551263

Please sign in to comment.