Skip to content

Commit

Permalink
delete old version of coreos after new one downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
jeefy committed Aug 11, 2024
1 parent 0fcec94 commit 1668f81
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/versions/coreos.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ func CoreOSVersionCheck() {
}

LoadRemoteCoreOSVersion()
oldVersion := viper.GetString(config.CurrentCoreOSVersion)
if viper.GetString(config.RemoteCoreOSVersion) != viper.GetString(config.CurrentCoreOSVersion) {
viper.Set(config.Updating, true)
log.Printf("Remote coreos version %s is different than local version %s", viper.GetString(config.RemoteCoreOSVersion), viper.GetString(config.CurrentCoreOSVersion))
log.Printf("Remote coreos version %s is different than local version %s", viper.GetString(config.RemoteCoreOSVersion), oldVersion)

if err := DownloadCoreOSJSON(); err != nil {
log.Printf("Error downloading coreos json: %s", err.Error())
Expand All @@ -76,6 +77,12 @@ func CoreOSVersionCheck() {
}

viper.Set(config.CurrentCoreOSVersion, viper.GetString(config.RemoteCoreOSVersion))

// Remove old versions once new ones are downloaded
os.Remove(fmt.Sprintf("fedora-coreos-%s-live-initramfs.%s.img", oldVersion, viper.GetString(config.CoreOSArchitecture)))
os.Remove(fmt.Sprintf("fedora-coreos-%s-live-kernel-%s", oldVersion, viper.GetString(config.CoreOSArchitecture)))
os.Remove(fmt.Sprintf("fedora-coreos-%s-live-rootfs.%s.img", oldVersion, viper.GetString(config.CoreOSArchitecture)))

viper.Set(config.Updating, false)
}

Expand Down

0 comments on commit 1668f81

Please sign in to comment.