From db64c6a7e134c21ed164550ab8ca626524e07268 Mon Sep 17 00:00:00 2001 From: "shylinux@163.com" Date: Fri, 26 Aug 2022 22:45:04 +0800 Subject: [PATCH] opt some --- base/mdb/hash.go | 2 -- base/nfs/dir.go | 13 ++++++------- base/nfs/pack.go | 6 +----- base/nfs/tar.go | 1 - base/web/spide.go | 3 --- core/code/install.go | 2 +- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/base/mdb/hash.go b/base/mdb/hash.go index 06a634e8..b08082f5 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -283,7 +283,6 @@ func HashTarget(m *ice.Message, h string, add Any) (p Any) { switch add := add.(type) { case func(ice.Map) ice.Any: p = add(value) - m.Debug("what %v %T", p, p) case func() ice.Any: p = add() default: @@ -292,7 +291,6 @@ func HashTarget(m *ice.Message, h string, add Any) (p Any) { } value[TARGET] = p } - m.Debug("what %v %T", p, p) }) return } diff --git a/base/nfs/dir.go b/base/nfs/dir.go index 7b7964ca..5dc10c46 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -29,10 +29,6 @@ func _dir_hash(m *ice.Message, p string) string { return "" } func _dir_list(m *ice.Message, root string, name string, level int, deep bool, dir_type string, dir_reg *regexp.Regexp, fields []string) *ice.Message { - if !aaa.Right(m, path.Join(root, name)) { - return m // 没有权限 - } - list, e := ReadDir(m, path.Join(root, name)) if e != nil || len(list) == 0 { // 单个文件 ls, _ := ReadDir(m, path.Dir(path.Join(root, name))) @@ -184,9 +180,12 @@ func init() { if m.Option(DIR_ROOT) != "" { m.Logs(mdb.SELECT, DIR_ROOT, m.Option(DIR_ROOT)) } - _dir_list(m, kit.Select(PWD, m.Option(DIR_ROOT)), kit.Select(PWD, arg, 0), - 0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), kit.Regexp(m.Option(DIR_REG)), - kit.Split(kit.Select(kit.Select(DIR_DEF_FIELDS, m.OptionFields()), kit.Join(kit.Slice(arg, 1))))) + root, name := kit.Select(PWD, m.Option(DIR_ROOT)), kit.Select(PWD, arg, 0) + if !aaa.Right(m, path.Join(root, name)) { + return // 没有权限 + } + fields := kit.Split(kit.Select(kit.Select(DIR_DEF_FIELDS, m.OptionFields()), kit.Join(kit.Slice(arg, 1)))) + _dir_list(m, root, name, 0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), kit.Regexp(m.Option(DIR_REG)), fields) m.SortTimeR(mdb.TIME) m.StatusTimeCount() }}, diff --git a/base/nfs/pack.go b/base/nfs/pack.go index c15ac5e4..1cd7a7f4 100644 --- a/base/nfs/pack.go +++ b/base/nfs/pack.go @@ -149,14 +149,10 @@ func CloseFile(m *ice.Message, p ice.Any) { func CopyFile(m *ice.Message, to io.WriteCloser, from io.ReadCloser, cb func(int)) { buf := make([]byte, 1024*1024) - total := 0 for { n, e := from.Read(buf) to.Write(buf[:n]) - cb(n) - total += n - m.Debug("what %v %v %v", n, total, e) - if e != nil { + if cb(n); e != nil { break } } diff --git a/base/nfs/tar.go b/base/nfs/tar.go index 252f0f79..b1c81102 100644 --- a/base/nfs/tar.go +++ b/base/nfs/tar.go @@ -33,7 +33,6 @@ func init() { }}, }, Hand: func(m *ice.Message, arg ...string) { m.Option("cmd_dir", m.Option(DIR_ROOT)) - m.Debug("cmd_dir: %v", m.Option("cmd_dir")) m.Cmdy("cli.system", "tar", "zcvf", arg) return diff --git a/base/web/spide.go b/base/web/spide.go index 76467c2d..5520c928 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -240,7 +240,6 @@ func _spide_send(m *ice.Message, name string, req *http.Request, timeout string) return client.Do(req) } func _spide_save(m *ice.Message, cache, save, uri string, res *http.Response) { - m.Debug("what %v", m.OptionCB("")) switch cache { case SPIDE_RAW: b, _ := ioutil.ReadAll(res.Body) @@ -265,13 +264,11 @@ func _spide_save(m *ice.Message, cache, save, uri string, res *http.Response) { defer f.Close() total := kit.Int(res.Header.Get(ContentLength)) + 1 - m.Debug("what %v", m.OptionCB("")) switch cb := m.OptionCB("").(type) { case func(int, int, int): count := 0 nfs.CopyFile(m, f, res.Body, func(n int) { count += n - m.Debug("what %v %v", n, count) cb(count, total, count*100/total) }) default: diff --git a/core/code/install.go b/core/code/install.go index b34f2293..2d895a66 100644 --- a/core/code/install.go +++ b/core/code/install.go @@ -151,7 +151,7 @@ func _install_trash(m *ice.Message, arg ...string) { m.Cmd(nfs.TRASH, kit.Path(ice.USR_LOCAL_DAEMON, m.Option(tcp.PORT), m.Option(nfs.PATH))) } func _install_service(m *ice.Message, arg ...string) { - arg = kit.Split(path.Base(arg[0]), "-.")[:1] + arg = kit.Split(path.Base(arg[0]), "_-.")[:1] m.Fields(len(arg[1:]), "time,port,status,pid,cmd,dir") m.Cmd(mdb.SELECT, cli.DAEMON, "", mdb.HASH, func(value ice.Maps) { if strings.Contains(value[ice.CMD], path.Join(ice.BIN, arg[0])) {