diff --git a/service/rauc.go b/service/rauc.go index 1fde2d6..58f1482 100644 --- a/service/rauc.go +++ b/service/rauc.go @@ -14,7 +14,7 @@ import ( ) const ( - FlagUpgradeFile = "/var/lib/casaos/upgradInfo.txt" + FlagUpgradeFile = "/var/lib/casaos/upgradeInfo.txt" ) func ExtractRAUCRelease(packageFilepath string, release codegen.Release) error { @@ -46,7 +46,7 @@ func InstallRAUC(release codegen.Release, sysRoot string, InstallRAUCHandler fun func InstallRAUCImp(raucFilePath string) error { // install rauc - fmt.Println("rauc路径为:", raucFilePath) + fmt.Println("rauc path: ", raucFilePath) raucInstaller, err := rauc.InstallerNew() if err != nil { @@ -71,7 +71,7 @@ func InstallRAUCImp(raucFilePath string) error { func MockInstallRAUC(raucFilePath string) error { // to check file exist - fmt.Println("文件名为", raucFilePath) + fmt.Println("filename: ", raucFilePath) if _, err := os.Stat(raucFilePath); os.IsNotExist(err) { return fmt.Errorf("not found rauc install package") } diff --git a/service/rauc_offline.go b/service/rauc_offline.go index 41e2c34..4fe125b 100644 --- a/service/rauc_offline.go +++ b/service/rauc_offline.go @@ -53,6 +53,10 @@ func (r *RAUCOfflineService) VerifyRelease(release codegen.Release) (string, err return r.CheckSumHandler(release) } +func CleanupOfflineRAUCTemp(sysRoot string) error { + return os.RemoveAll(filepath.Join(sysRoot, config.OFFLINE_RAUC_TEMP_PATH)) +} + func (r *RAUCOfflineService) DownloadRelease(ctx context.Context, release codegen.Release, force bool) (string, error) { releasePath, err := r.VerifyRelease(release) if err != nil { diff --git a/service/release.go b/service/release.go index b2d3373..d9e6021 100644 --- a/service/release.go +++ b/service/release.go @@ -19,6 +19,8 @@ import ( "github.com/Masterminds/semver/v3" "go.uber.org/zap" "gopkg.in/yaml.v3" + + "github.com/samber/lo" ) var ( @@ -229,7 +231,16 @@ func CheckOfflineTarExist(sysRoot string) bool { // if the file have "*.tar" return true files := internal.GetAllFile(filepath.Join(sysRoot, config.RAUC_OFFLINE_PATH)) println("files : ", files) - if len(files) == 1 { + + // only allow one tar file + tar_files := lo.FilterMap(files, func(filename string, _ int) (string, bool) { + if strings.HasSuffix(filename, ".tar") { + return filename, true + } + return "", false + }) + + if len(tar_files) == 1 { file_name := files[0] if strings.HasSuffix(file_name, ".tar") { println("find offline rauc file: ", file_name) diff --git a/service/service.go b/service/service.go index 10fc464..06ec0e7 100644 --- a/service/service.go +++ b/service/service.go @@ -168,6 +168,8 @@ func NewService(RuntimePath string) Services { } func NewInstallerService(sysRoot string) UpdaterServiceInterface { + + CleanupOfflineRAUCTemp(sysRoot) installMethod, err := GetInstallMethod(sysRoot) if err != nil { panic(err) diff --git a/types/installer_type.go b/types/installer_type.go index 5a6a48a..b8af4a3 100644 --- a/types/installer_type.go +++ b/types/installer_type.go @@ -9,8 +9,7 @@ const ( type TriggerType string const ( - HTTP_CHECK TriggerType = "http-request-check" - + HTTP_CHECK TriggerType = "http-request-check" HTTP_REQUEST TriggerType = "http-request-trigger" CRON_JOB TriggerType = "cron-job-trigger" INSTALL TriggerType = "install-trigger"