Skip to content

Commit 438b8a1

Browse files
committed
Solve the problem of local application import failure
1 parent ca967ec commit 438b8a1

File tree

6 files changed

+58
-2
lines changed

6 files changed

+58
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
### Fixed
2020

21-
## [0.3.7]
21+
## [0.3.7.1] 2022-11-04
22+
23+
### Fixed
24+
25+
- Fix memory leak issue ([#658](https://github.com/IceWhaleTech/CasaOS/issues/658)[#646](https://github.com/IceWhaleTech/CasaOS/issues/646))
26+
- Solve the problem of local application import failure ([#490](https://github.com/IceWhaleTech/CasaOS/issues/490))
27+
28+
## [0.3.7] 2022-10-28
2229

2330
### Added
2431
- [Storage] Disk merge (Beta), you can merge multiple disks into a single storage space (currently you need to enable this feature from the command line)

model/sys_common.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,8 @@ type FileSetting struct {
7474
ShareDir []string `json:"share_dir" delim:"|"`
7575
DownloadDir string `json:"download_dir"`
7676
}
77+
type BaseInfo struct {
78+
Hash string `json:"i"`
79+
Version string `json:"v"`
80+
Channel string `json:"c,omitempty"`
81+
}

route/init.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,55 @@
11
package route
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"os"
67
"strings"
78
"time"
89

10+
"github.com/IceWhaleTech/CasaOS/model"
11+
"github.com/IceWhaleTech/CasaOS/pkg/config"
912
"github.com/IceWhaleTech/CasaOS/pkg/samba"
13+
"github.com/IceWhaleTech/CasaOS/pkg/utils/encryption"
1014
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
1115
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
1216
"github.com/IceWhaleTech/CasaOS/service"
17+
"github.com/IceWhaleTech/CasaOS/types"
1318
"go.uber.org/zap"
1419
)
1520

1621
func InitFunction() {
1722
go InitNetworkMount()
23+
go InitInfo()
1824
}
25+
26+
func InitInfo() {
27+
mb := model.BaseInfo{}
28+
if file.Exists(config.AppInfo.DBPath + "/baseinfo.conf") {
29+
err := json.Unmarshal(file.ReadFullFile(config.AppInfo.DBPath+"/baseinfo.conf"), &mb)
30+
if err != nil {
31+
loger.Error("baseinfo.conf", zap.String("error", err.Error()))
32+
}
33+
}
34+
if file.Exists("/etc/CHANNEL") {
35+
channel := file.ReadFullFile("/etc/CHANNEL")
36+
mb.Channel = string(channel)
37+
}
38+
mac, err := service.MyService.System().GetMacAddress()
39+
if err != nil {
40+
loger.Error("GetMacAddress", zap.String("error", err.Error()))
41+
}
42+
mb.Hash = encryption.GetMD5ByStr(mac)
43+
mb.Version = types.CURRENTVERSION
44+
os.Remove(config.AppInfo.DBPath + "/baseinfo.conf")
45+
by, err := json.Marshal(mb)
46+
if err != nil {
47+
loger.Error("init info err", zap.Any("err", err))
48+
return
49+
}
50+
file.WriteToFullPath(by, config.AppInfo.DBPath+"/baseinfo.conf", 0o666)
51+
}
52+
1953
func InitNetworkMount() {
2054
time.Sleep(time.Second * 10)
2155
connections := service.MyService.Connections().GetConnectionsList()

service/docker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ func (ds *dockerService) DockerContainerCreate(m model.CustomizationPostData, id
560560
//container, err := cli.ContainerCreate(context.Background(), info.Config, info.HostConfig, &network.NetworkingConfig{info.NetworkSettings.Networks}, nil, info.Name)
561561

562562
hostConfig.Mounts = volumes
563+
hostConfig.Binds = []string{}
563564
hostConfig.Privileged = m.Privileged
564565
hostConfig.CapAdd = m.CapAdd
565566
hostConfig.NetworkMode = container.NetworkMode(m.NetworkModel)

service/system.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,18 @@ type SystemService interface {
5050
IsServiceRunning(name string) bool
5151
GetCPUTemperature() int
5252
GetCPUPower() map[string]string
53+
GetMacAddress() (string, error)
5354
}
5455
type systemService struct{}
5556

57+
func (c *systemService) GetMacAddress() (string, error) {
58+
interfaces, err := net.Interfaces()
59+
if err != nil {
60+
return "", err
61+
}
62+
inter := interfaces[0]
63+
return inter.HardwareAddr, nil
64+
}
5665
func (c *systemService) MkdirAll(path string) (int, error) {
5766
_, err := os.Stat(path)
5867
if err == nil {

types/system.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
*/
1010
package types
1111

12-
const CURRENTVERSION = "0.3.7"
12+
const CURRENTVERSION = "0.3.7.1"
1313

1414
const BODY = " "

0 commit comments

Comments
 (0)