From 39ccbe251faac7aac3a3484f8ae847f3ecf38f3c Mon Sep 17 00:00:00 2001 From: link Date: Tue, 19 Oct 2021 19:07:16 +0800 Subject: [PATCH] Optimize installation process auto create file or dir --- UI | 2 +- service/docker.go | 6 ++++-- service/zima_info.go | 9 ++------- types/system.go | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/UI b/UI index 0a78d55..645e6ca 160000 --- a/UI +++ b/UI @@ -1 +1 @@ -Subproject commit 0a78d55a82dbeb10e617189358f8747629045377 +Subproject commit 645e6cac7dcc188d310b7fa7add3d03688021d23 diff --git a/service/docker.go b/service/docker.go index 25b2e74..5055338 100644 --- a/service/docker.go +++ b/service/docker.go @@ -7,6 +7,7 @@ import ( "encoding/binary" json2 "encoding/json" "fmt" + "regexp" "syscall" model2 "github.com/IceWhaleTech/CasaOS/service/model" @@ -417,9 +418,10 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s if len(path) == 0 { continue } - } - if strings.HasSuffix(path, "/") { + reg1 := regexp.MustCompile(`([^<>/\\\|:""\*\?]+\.\w+$)`) + result1 := reg1.FindAllStringSubmatch(path, -1) + if len(result1) == 0 { err = file.IsNotExistMkDir(path) if err != nil { ds.log.Error("mkdir error", err) diff --git a/service/zima_info.go b/service/zima_info.go index 86f6000..4770ff8 100644 --- a/service/zima_info.go +++ b/service/zima_info.go @@ -84,14 +84,9 @@ func (c *zima) GetDirPath(path string) []model.Path { ls, _ := ioutil.ReadDir(path) dirs := []model.Path{} - if strings.Count(path, "/") > 1 { + if strings.Count(path, "/") > 0 { for _, l := range ls { - pathTemp := path + l.Name() - if l.IsDir() { - pathTemp += "/" - } - - dirs = append(dirs, model.Path{Name: l.Name(), Path: pathTemp, IsDir: l.IsDir()}) + dirs = append(dirs, model.Path{Name: l.Name(), Path: path + "/" + l.Name(), IsDir: l.IsDir()}) } } else { dirs = append(dirs, model.Path{Name: "DATA", Path: "/DATA/", IsDir: true}) diff --git a/types/system.go b/types/system.go index 4793dc3..7c533c9 100644 --- a/types/system.go +++ b/types/system.go @@ -1,4 +1,4 @@ package types const CURRENTVERSION = "0.1.6" -const BODY = "
  • Add a file selector for app install.
  • Fixed an issue with the app were it would disappear when the app was modified.
  • " +const BODY = "
  • Modify import reminder.
  • Add app icon auto-fill via docker image name.
  • Add a file selector for app install.
  • Fixed an issue with the app were it would disappear when the app was modified.
  • "