Update license.go (handled error) (#28410)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
63c97f5a6d
Коммит
9726eedbe2
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user