From fbdf3cbd14946247c918fd26b24b14703757c3a4 Mon Sep 17 00:00:00 2001 From: Arya Khochare <91268931+Aryakoste@users.noreply.github.com> Date: Thu, 24 Oct 2024 23:23:48 +0530 Subject: [PATCH] Fixed errcheck issues in server/channels/api4/license_local.go (#28558) Co-authored-by: Ben Schumacher --- server/.golangci.yml | 1 - server/channels/api4/license_local.go | 5 ++++- server/i18n/en.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/.golangci.yml b/server/.golangci.yml index 0db2af8e1a587..56d797d028a9c 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -74,7 +74,6 @@ issues: channels/api4/data_retention.go|\ channels/api4/file_test.go|\ channels/api4/job_test.go|\ - channels/api4/license_local.go|\ channels/api4/post_test.go|\ channels/api4/preference_test.go|\ channels/api4/reaction_test.go|\ diff --git a/server/channels/api4/license_local.go b/server/channels/api4/license_local.go index 55625148b08e6..524396ec468b2 100644 --- a/server/channels/api4/license_local.go +++ b/server/channels/api4/license_local.go @@ -54,7 +54,10 @@ func localAddLicense(c *Context, w http.ResponseWriter, r *http.Request) { defer file.Close() buf := bytes.NewBuffer(nil) - io.Copy(buf, file) + if _, err := io.Copy(buf, file); err != nil { + c.Err = model.NewAppError("addLicense", "api.license.add_license.copy.app_error", nil, "", http.StatusInternalServerError).Wrap(err) + return + } license, appErr := c.App.Srv().SaveLicense(buf.Bytes()) if appErr != nil { diff --git a/server/i18n/en.json b/server/i18n/en.json index 406c708ad0c18..fb656dc6473da 100644 --- a/server/i18n/en.json +++ b/server/i18n/en.json @@ -2234,7 +2234,7 @@ }, { "id": "api.license.add_license.copy.app_error", - "translation": "Failed to copy license." + "translation": "Failed to copy license file content to buffer" }, { "id": "api.license.add_license.expired.app_error",