CasaOS/pkg/utils/version/version.go

45 lines
892 B
Go
Raw Normal View History

/*
* @Author: LinkLeong link@icewhale.com
* @Date: 2022-05-13 18:15:46
* @LastEditors: LinkLeong
* @LastEditTime: 2022-07-21 15:27:53
* @FilePath: /CasaOS/pkg/utils/version/version.go
* @Description:
* @Website: https://www.casaos.io
* Copyright (c) 2022 by icewhale, All Rights Reserved.
*/
2021-09-26 02:35:02 +00:00
package version
import (
"strconv"
"strings"
"github.com/IceWhaleTech/CasaOS/common"
2021-09-27 06:17:36 +00:00
"github.com/IceWhaleTech/CasaOS/model"
2021-09-26 02:35:02 +00:00
)
func IsNeedUpdate(version model.Version) (bool, model.Version) {
2021-09-26 02:35:02 +00:00
v1 := strings.Split(version.Version, ".")
Dev (#288) * fix bug * updata UI * 0.3.2 ### Added - [Files] Files can now be selected multiple files and downloaded, deleted, moved, etc. - [Apps] Support to modify the application opening address.([#204](https://github.com/IceWhaleTech/CasaOS/issues/204)) ### Changed - [Apps] Hide the display of non-essential environment variables in the application. - [System] Network, disk, cpu, memory, etc. information is modified to be pushed via socket. - [System] Optimize opening speed.([#214](https://github.com/IceWhaleTech/CasaOS/issues/214)) ### Fixed - [System] Fixed the problem that sync data cannot submit the device ID ([#68](https://github.com/IceWhaleTech/CasaOS/issues/68)) - [Files] Fixed the code editor center alignment display problem.([#210](https://github.com/IceWhaleTech/CasaOS/issues/210)) - [Files] Fixed the problem of wrong name when downloading files.([#240](https://github.com/IceWhaleTech/CasaOS/issues/240)) - [System] Fixed the network display as a negative number problem.([#224](https://github.com/IceWhaleTech/CasaOS/issues/224)) * Modify log help class * Fix some bugs in 0.3.2 * Solve the operation file queue problem * Exclude web folders * update UI * add cancel file operate * Update UI * Merge sockets to transfer data * Conflict Resolution * Update send data interval * Update UI * fixed bug - Fix the problem of application opening failure on non-80 ports - Modify port failure problem - Modify environment variables disappearing problem * update version function * Fix version update issues
2022-06-14 05:24:53 +00:00
v2 := strings.Split(common.VERSION, ".")
2021-09-26 02:35:02 +00:00
for len(v1) < len(v2) {
v1 = append(v1, "0")
}
for len(v2) < len(v1) {
v2 = append(v2, "0")
}
for i := 0; i < len(v1); i++ {
a, _ := strconv.Atoi(v1[i])
b, _ := strconv.Atoi(v2[i])
if a > b {
return true, version
2022-05-05 05:46:55 +00:00
}
if a < b {
return false, version
}
2022-05-05 05:46:55 +00:00
}
return false, version
}