1
0
forked from x/icebergs
This commit is contained in:
shylinux@163.com 2022-08-26 22:45:04 +08:00
parent 8f12abd2f5
commit db64c6a7e1
6 changed files with 8 additions and 19 deletions

View File

@ -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
}

View File

@ -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()
}},

View File

@ -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
}
}

View File

@ -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

View File

@ -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:

View File

@ -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])) {