[MM-61765] Fix errcheck issues in server/channels/app/platform/license.go (#30954)
* [MM-61765] Fix errcheck issues in server/channels/app/platform/license.go - Removed the errcheck exception for license.go from .golangci.yml - Added proper error handling for RemoveLicense() calls - Added proper error handling for ReloadConfig() and InvalidateAllCaches() calls - Updated variable names to avoid conflicts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * simplify naming --------- Co-authored-by: Claude <noreply@anthropic.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4dbff921ba
Коммит
bb8aabc15e
@@ -94,7 +94,6 @@ issues:
|
||||
channels/app/helper_test.go|\
|
||||
channels/app/permissions_test.go|\
|
||||
channels/app/platform/helper_test.go|\
|
||||
channels/app/platform/license.go|\
|
||||
channels/store/localcachelayer/channel_layer.go|\
|
||||
channels/store/localcachelayer/channel_layer_test.go|\
|
||||
channels/store/localcachelayer/emoji_layer.go|\
|
||||
|
||||
@@ -183,15 +183,16 @@ func (ps *PlatformService) SaveLicense(licenseBytes []byte) (*model.License, *mo
|
||||
record.Id = license.Id
|
||||
record.Bytes = string(licenseBytes)
|
||||
|
||||
nErr := ps.Store.License().Save(record)
|
||||
if nErr != nil {
|
||||
ps.RemoveLicense()
|
||||
if err := ps.Store.License().Save(record); err != nil {
|
||||
if appErr := ps.RemoveLicense(); appErr != nil {
|
||||
ps.logger.Error("Failed to remove license after saving it to the license store failed", mlog.Err(appErr))
|
||||
}
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(nErr, &appErr):
|
||||
case errors.As(err, &appErr):
|
||||
return nil, appErr
|
||||
default:
|
||||
return nil, model.NewAppError("addLicense", "api.license.add_license.save.app_error", nil, "", http.StatusInternalServerError).Wrap(nErr)
|
||||
return nil, model.NewAppError("addLicense", "api.license.add_license.save.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,8 +200,11 @@ func (ps *PlatformService) SaveLicense(licenseBytes []byte) (*model.License, *mo
|
||||
sysVar.Name = model.SystemActiveLicenseId
|
||||
sysVar.Value = license.Id
|
||||
if err := ps.Store.System().SaveOrUpdate(sysVar); err != nil {
|
||||
ps.RemoveLicense()
|
||||
return nil, model.NewAppError("addLicense", "api.license.add_license.save_active.app_error", nil, "", http.StatusInternalServerError)
|
||||
appErr := ps.RemoveLicense()
|
||||
if appErr != nil {
|
||||
ps.logger.Error("Failed to remove license after saving it to the system store failed", mlog.Err(appErr))
|
||||
}
|
||||
return nil, model.NewAppError("addLicense", "api.license.add_license.save_active.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
// only on prem licenses set this in the first place
|
||||
if !license.IsCloud() {
|
||||
@@ -210,8 +214,12 @@ func (ps *PlatformService) SaveLicense(licenseBytes []byte) (*model.License, *mo
|
||||
}
|
||||
}
|
||||
|
||||
ps.ReloadConfig()
|
||||
ps.InvalidateAllCaches()
|
||||
if err := ps.ReloadConfig(); err != nil {
|
||||
ps.logger.Warn("Failed to reload config after saving license", mlog.Err(err))
|
||||
}
|
||||
if appErr := ps.InvalidateAllCaches(); appErr != nil {
|
||||
ps.logger.Warn("Failed to invalidate cache after saving license", mlog.Err(appErr))
|
||||
}
|
||||
|
||||
return &license, nil
|
||||
}
|
||||
@@ -295,8 +303,12 @@ func (ps *PlatformService) RemoveLicense() *model.AppError {
|
||||
}
|
||||
|
||||
ps.SetLicense(nil)
|
||||
ps.ReloadConfig()
|
||||
ps.InvalidateAllCaches()
|
||||
if err := ps.ReloadConfig(); err != nil {
|
||||
ps.logger.Warn("Failed to reload config after removing license", mlog.Err(err))
|
||||
}
|
||||
if appErr := ps.InvalidateAllCaches(); appErr != nil {
|
||||
ps.logger.Warn("Failed to invalidate cache after removing license", mlog.Err(appErr))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -352,8 +364,12 @@ func (ps *PlatformService) RequestTrialLicense(trialRequest *model.TrialLicenseR
|
||||
return err
|
||||
}
|
||||
|
||||
ps.ReloadConfig()
|
||||
ps.InvalidateAllCaches()
|
||||
if err := ps.ReloadConfig(); err != nil {
|
||||
ps.logger.Warn("Failed to reload config after requesting trial license", mlog.Err(err))
|
||||
}
|
||||
if appErr := ps.InvalidateAllCaches(); appErr != nil {
|
||||
ps.logger.Warn("Failed to invalidate cache after requesting trial license", mlog.Err(appErr))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user