Fix some bugs in 0.3.2
2
UI
@ -1 +1 @@
|
||||
Subproject commit 16e62b4cf09537cf2c0a3816c3da43bd3af373a1
|
||||
Subproject commit c84725c4e94e898e0eb91167e729dc3faa3991d2
|
||||
@ -1,5 +1,18 @@
|
||||
/*
|
||||
* @Author: link a624669980@163.com
|
||||
* @Date: 2022-05-16 17:37:08
|
||||
* @LastEditors: link a624669980@163.com
|
||||
* @LastEditTime: 2022-06-07 17:12:30
|
||||
* @FilePath: \CasaOS\model\category.go
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
|
||||
*/
|
||||
package model
|
||||
|
||||
// type ServerCategoryList struct {
|
||||
// Version string `json:"version"`
|
||||
// Item []CategoryList `json:"item"`
|
||||
// }
|
||||
type ServerCategoryList struct {
|
||||
Id uint `gorm:"column:id;primary_key" json:"id"`
|
||||
//CreatedAt time.Time `json:"created_at"`
|
||||
|
||||
@ -4,8 +4,8 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
json2 "encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -683,11 +683,11 @@ func UnInstallApp(c *gin.Context) {
|
||||
service.MyService.Docker().DockerImageRemove(info.Config.Image)
|
||||
|
||||
if info.Config.Labels["origin"] != "custom" {
|
||||
fmt.Println(info.HostConfig.Mounts)
|
||||
//step: 删除文件夹
|
||||
for _, v := range info.HostConfig.Mounts {
|
||||
for _, v := range info.Mounts {
|
||||
if strings.Contains(v.Source, info.Name) {
|
||||
service.MyService.App().DelAppConfigDir(v.Source)
|
||||
path := filepath.Join(strings.Split(v.Source, info.Name)[0], info.Name)
|
||||
service.MyService.App().DelAppConfigDir(path)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1164,7 +1164,7 @@ func ContainerUpdateInfo(c *gin.Context) {
|
||||
//appInfo := service.MyService.App().GetAppDBInfo(appId)
|
||||
info, err := service.MyService.Docker().DockerContainerInfo(appId)
|
||||
if err != nil {
|
||||
//todo 需要自定义错误
|
||||
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@ -274,7 +274,22 @@ func DirPath(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: info})
|
||||
//Hide the files or folders in operation
|
||||
fileQueue := make(map[string]string)
|
||||
for _, v := range service.FileQueue {
|
||||
for _, i := range v.Item {
|
||||
lastPath := i.From[strings.LastIndex(i.From, "/")+1:]
|
||||
fileQueue[v.To+"/"+lastPath] = i.From
|
||||
}
|
||||
}
|
||||
pathList := []model.Path{}
|
||||
for i := 0; i < len(info); i++ {
|
||||
if _, ok := fileQueue[info[i].Path]; !ok {
|
||||
pathList = append(pathList, info[i])
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: pathList})
|
||||
}
|
||||
|
||||
// @Summary rename file or dir
|
||||
@ -489,12 +504,18 @@ func PostOperateFileOrDir(c *gin.Context) {
|
||||
|
||||
uid := uuid.NewV4().String()
|
||||
service.FileQueue[uid] = list
|
||||
service.OpStrArr = append(service.OpStrArr, uid)
|
||||
if len(service.OpFile) == 0 {
|
||||
service.OpFile = make(chan string, 1)
|
||||
go service.FileOperate()
|
||||
go service.Op()
|
||||
}
|
||||
|
||||
if len(service.FileQueue) == 1 {
|
||||
go service.MyService.Notify().SendFileOperateNotify()
|
||||
go service.CheckFileStatus()
|
||||
|
||||
}
|
||||
go service.FileOperate(list)
|
||||
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS)})
|
||||
}
|
||||
@ -553,13 +574,11 @@ func PutFileContent(c *gin.Context) {
|
||||
//err := os.Remove(path)
|
||||
err := os.RemoveAll(fi.FilePath)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.FILE_DELETE_ERROR, Message: oasis_err2.GetMsg(oasis_err2.FILE_DELETE_ERROR), Data: err})
|
||||
return
|
||||
}
|
||||
err = file.CreateFileAndWriteContent(fi.FilePath, fi.FileContent)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.ERROR, Message: oasis_err2.GetMsg(oasis_err2.ERROR), Data: err})
|
||||
return
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
json2 "encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
@ -78,7 +79,7 @@ func (o *casaService) GetServerList(index, size, tp, categoryId, key, language s
|
||||
json2.Unmarshal([]byte(gjson.Get(listS, "data.community").String()), &community)
|
||||
|
||||
if len(list) > 0 {
|
||||
Cache.SetDefault(keyName, listS)
|
||||
Cache.Set(keyName, listS, time.Hour*24)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -101,10 +102,48 @@ func (o *casaService) GetServerCategoryList() (list []model.ServerCategoryList)
|
||||
|
||||
json2.Unmarshal([]byte(gjson.Get(listS, "data").String()), &list)
|
||||
if len(list) > 0 {
|
||||
Cache.SetDefault(keyName, listS)
|
||||
Cache.Set(keyName, listS, time.Hour*24)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// func (o *casaService) GetServerCategoryList() (list model.ServerCategoryList) {
|
||||
|
||||
// results := file.ReadFullFile(config.AppInfo.ProjectPath + "/conf/app_category.json")
|
||||
// err := json2.Unmarshal(results, &list)
|
||||
// if err != nil {
|
||||
// loger.Error("marshal error", zap.Any("err", err), zap.Any("content", string(results)))
|
||||
// }
|
||||
// return list
|
||||
// }
|
||||
|
||||
// func (o *casaService) AsyncGetServerCategoryList() {
|
||||
// list := model.ServerCategoryList{}
|
||||
// results := file.ReadFullFile(config.AppInfo.ProjectPath + "/conf/app_category.json")
|
||||
// err := json2.Unmarshal(results, &list)
|
||||
// if err != nil {
|
||||
// loger.Error("marshal error", zap.Any("err", err), zap.Any("content", string(results)))
|
||||
// }
|
||||
|
||||
// if list.Version == GetAppVersion() {
|
||||
// return
|
||||
// }
|
||||
// item := []model.CategoryList{}
|
||||
// head := make(map[string]string)
|
||||
// head["Authorization"] = GetToken()
|
||||
// listS := httper2.Get(config.ServerInfo.ServerApi+"/v2/app/category", head)
|
||||
// json2.Unmarshal([]byte(gjson.Get(listS, "data").String()), &item)
|
||||
// if len(item) > 0 {
|
||||
// list.Version = GetAppVersion()
|
||||
// list.Item = item
|
||||
// by, err := json.Marshal(list)
|
||||
// if err != nil {
|
||||
// loger.Error("marshal error", zap.Any("err", err))
|
||||
// }
|
||||
// file.WriteToPath(by, config.AppInfo.ProjectPath+"/conf", "app_category.json")
|
||||
// }
|
||||
// }
|
||||
|
||||
func (o *casaService) GetServerAppInfo(id, t string, language string) model.ServerAppList {
|
||||
|
||||
head := make(map[string]string)
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* @Author: LinkLeong link@icewhale.com
|
||||
* @Date: 2021-12-20 14:15:46
|
||||
* @LastEditors: LinkLeong
|
||||
* @LastEditTime: 2022-05-30 18:49:46
|
||||
* @LastEditors: link a624669980@163.com
|
||||
* @LastEditTime: 2022-06-07 22:21:29
|
||||
* @FilePath: /CasaOS/service/file.go
|
||||
* @Description:
|
||||
* @Website: https://www.casaos.io
|
||||
@ -12,6 +12,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -23,6 +24,9 @@ import (
|
||||
)
|
||||
|
||||
var FileQueue map[string]model.FileOperate
|
||||
var OpFile chan string
|
||||
|
||||
var OpStrArr []string
|
||||
|
||||
type reader struct {
|
||||
ctx context.Context
|
||||
@ -73,7 +77,9 @@ func (w *writer) Write(p []byte) (n int, err error) {
|
||||
return w.w.Write(p)
|
||||
}
|
||||
}
|
||||
func FileOperate(list model.FileOperate) {
|
||||
func FileOperate() {
|
||||
for i := range OpFile {
|
||||
list := FileQueue[i]
|
||||
for _, v := range list.Item {
|
||||
if list.Type == "move" {
|
||||
lastPath := v.From[strings.LastIndex(v.From, "/")+1:]
|
||||
@ -95,6 +101,21 @@ func FileOperate(list model.FileOperate) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func Op() {
|
||||
for {
|
||||
//TODO:Debugging is also required. .
|
||||
if len(OpStrArr) == 0 {
|
||||
close(OpFile)
|
||||
return
|
||||
}
|
||||
fmt.Println("start")
|
||||
OpFile <- OpStrArr[0]
|
||||
fmt.Println("end")
|
||||
}
|
||||
}
|
||||
|
||||
// file move or copy and send notify
|
||||
func CheckFileStatus() {
|
||||
for {
|
||||
|
||||
@ -69,6 +69,7 @@ func (i *notifyServer) SendFileOperateNotify() {
|
||||
task.Finished = true
|
||||
task.Status = "FINISHED"
|
||||
delete(FileQueue, k)
|
||||
OpStrArr = OpStrArr[1:]
|
||||
list = append(list, task)
|
||||
break
|
||||
}
|
||||
|
||||
@ -57,7 +57,6 @@ func (c *systemService) GetCpuCoreNum() int {
|
||||
|
||||
func (c *systemService) GetNetInfo() []net.IOCountersStat {
|
||||
parts, _ := net.IOCounters(true)
|
||||
//fmt.Println(net.ConntrackStatsWithContext(true))
|
||||
return parts
|
||||
}
|
||||
func (c *systemService) GetNet(physics bool) []string {
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 982 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 834 B After Width: | Height: | Size: 834 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 874 B After Width: | Height: | Size: 874 B |
|
Before Width: | Height: | Size: 813 B After Width: | Height: | Size: 813 B |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 917 B After Width: | Height: | Size: 917 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 953 B After Width: | Height: | Size: 953 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 855 B After Width: | Height: | Size: 855 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 955 B After Width: | Height: | Size: 955 B |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1003 B After Width: | Height: | Size: 1003 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 928 B After Width: | Height: | Size: 928 B |
|
Before Width: | Height: | Size: 949 B After Width: | Height: | Size: 949 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |