mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-06 21:39:50 +08:00
feat(appstore): Add MD5 Checksum for Custom Application Store Packages (#7629)
This commit is contained in:
parent
992fecb16a
commit
c7936e656b
2 changed files with 20 additions and 4 deletions
|
@ -414,13 +414,13 @@ func (a *AppInstallService) Update(req request.AppInstalledUpdate) error {
|
|||
go func() {
|
||||
nginxInstall, err := getNginxFull(&website)
|
||||
if err != nil {
|
||||
global.LOG.Errorf(buserr.WithErr(constant.ErrUpdateBuWebsite, err).Error())
|
||||
global.LOG.Error(buserr.WithErr(constant.ErrUpdateBuWebsite, err).Error())
|
||||
return
|
||||
}
|
||||
config := nginxInstall.SiteConfig.Config
|
||||
servers := config.FindServers()
|
||||
if len(servers) == 0 {
|
||||
global.LOG.Errorf(buserr.WithErr(constant.ErrUpdateBuWebsite, errors.New("nginx config is not valid")).Error())
|
||||
global.LOG.Error(buserr.WithErr(constant.ErrUpdateBuWebsite, errors.New("nginx config is not valid")).Error())
|
||||
return
|
||||
}
|
||||
server := servers[0]
|
||||
|
@ -428,11 +428,11 @@ func (a *AppInstallService) Update(req request.AppInstalledUpdate) error {
|
|||
server.UpdateRootProxy([]string{proxy})
|
||||
|
||||
if err := nginx.WriteConfig(config, nginx.IndentedStyle); err != nil {
|
||||
global.LOG.Errorf(buserr.WithErr(constant.ErrUpdateBuWebsite, err).Error())
|
||||
global.LOG.Error(buserr.WithErr(constant.ErrUpdateBuWebsite, err).Error())
|
||||
return
|
||||
}
|
||||
if err := nginxCheckAndReload(nginxInstall.SiteConfig.OldContent, config.FilePath, nginxInstall.Install.ContainerName); err != nil {
|
||||
global.LOG.Errorf(buserr.WithErr(constant.ErrUpdateBuWebsite, err).Error())
|
||||
global.LOG.Error(buserr.WithErr(constant.ErrUpdateBuWebsite, err).Error())
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
|
|
@ -2,6 +2,8 @@ package files
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -169,3 +171,17 @@ func Stat(path string) bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetFileMD5(filePath string) (string, error) {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer file.Close()
|
||||
hash := md5.New()
|
||||
|
||||
if _, err = io.Copy(hash, file); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return hex.EncodeToString(hash.Sum(nil)), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue