Update license.go (handled error) (#28410)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
63c97f5a6d
Коммит
9726eedbe2
@@ -76,7 +76,6 @@ issues:
|
||||
channels/api4/file_test.go|\
|
||||
channels/api4/ip_filtering_test.go|\
|
||||
channels/api4/job_test.go|\
|
||||
channels/api4/license.go|\
|
||||
channels/api4/license_local.go|\
|
||||
channels/api4/post_test.go|\
|
||||
channels/api4/preference_test.go|\
|
||||
|
||||
@@ -45,7 +45,9 @@ func getClientLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
clientLicense = c.App.Srv().GetSanitizedClientLicense()
|
||||
}
|
||||
|
||||
w.Write([]byte(model.MapToJSON(clientLicense)))
|
||||
if _, err := w.Write([]byte(model.MapToJSON(clientLicense))); err != nil {
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
@@ -93,7 +95,10 @@ func addLicense(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
|
||||
}
|
||||
|
||||
licenseBytes := buf.Bytes()
|
||||
license, appErr := utils.LicenseValidator.LicenseFromBytes(licenseBytes)
|
||||
@@ -137,7 +142,11 @@ func addLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if c.App.Channels().License().IsCloud() {
|
||||
// If cloud, invalidate the caches when a new license is loaded
|
||||
defer c.App.Srv().Cloud.HandleLicenseChange()
|
||||
defer func() {
|
||||
if err := c.App.Srv().Cloud.HandleLicenseChange(); err != nil {
|
||||
c.Logger.Warn("Error while handling license change", mlog.Err(err))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
auditRec.Success()
|
||||
@@ -258,5 +267,8 @@ func getPrevTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
clientLicense = utils.GetSanitizedClientLicense(utils.GetClientLicense(license))
|
||||
}
|
||||
|
||||
w.Write([]byte(model.MapToJSON(clientLicense)))
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if _, err := w.Write([]byte(model.MapToJSON(clientLicense))); err != nil {
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2224,6 +2224,10 @@
|
||||
"id": "api.license.add_license.array.app_error",
|
||||
"translation": "Empty array under 'license' in request."
|
||||
},
|
||||
{
|
||||
"id": "api.license.add_license.copy.app_error",
|
||||
"translation": "Failed to copy license."
|
||||
},
|
||||
{
|
||||
"id": "api.license.add_license.expired.app_error",
|
||||
"translation": "License is either expired or has not yet started."
|
||||
|
||||
Ссылка в новой задаче
Block a user