mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-12 05:15:59 +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() {
|
go func() {
|
||||||
nginxInstall, err := getNginxFull(&website)
|
nginxInstall, err := getNginxFull(&website)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.LOG.Errorf(buserr.WithErr(constant.ErrUpdateBuWebsite, err).Error())
|
global.LOG.Error(buserr.WithErr(constant.ErrUpdateBuWebsite, err).Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
config := nginxInstall.SiteConfig.Config
|
config := nginxInstall.SiteConfig.Config
|
||||||
servers := config.FindServers()
|
servers := config.FindServers()
|
||||||
if len(servers) == 0 {
|
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
|
return
|
||||||
}
|
}
|
||||||
server := servers[0]
|
server := servers[0]
|
||||||
|
|
@ -428,11 +428,11 @@ func (a *AppInstallService) Update(req request.AppInstalledUpdate) error {
|
||||||
server.UpdateRootProxy([]string{proxy})
|
server.UpdateRootProxy([]string{proxy})
|
||||||
|
|
||||||
if err := nginx.WriteConfig(config, nginx.IndentedStyle); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
if err := nginxCheckAndReload(nginxInstall.SiteConfig.OldContent, config.FilePath, nginxInstall.Install.ContainerName); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package files
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -169,3 +171,17 @@ func Stat(path string) bool {
|
||||||
}
|
}
|
||||||
return true
|
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