From 4bc53b776431ab0328a340e103c8665aa16f0757 Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 10 Apr 2022 12:56:58 +0800 Subject: [PATCH] opt some --- base/web/share.go | 4 +++- base/web/spide.go | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/base/web/share.go b/base/web/share.go index 9b7a24fd..f1d4a7eb 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -75,13 +75,15 @@ func _share_local(m *ice.Message, arg ...string) { if m.Option(ice.POD) != "" { // 远程文件 pp := path.Join(ice.VAR_PROXY, m.Option(ice.POD), p) cache := time.Now().Add(-time.Hour * 240000) + var size int64 if s, e := os.Stat(pp); e == nil { cache = s.ModTime() + size = s.Size() } // 上传文件 m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY, nfs.PATH, ""), - SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p) + SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p) if s, e := os.Stat(pp); e == nil && !s.IsDir() { p = pp diff --git a/base/web/spide.go b/base/web/spide.go index fe658e4e..a31d27fa 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -183,7 +183,11 @@ func _spide_part(m *ice.Message, arg ...string) (io.Reader, string) { defer mp.Close() cache := time.Now().Add(-time.Hour * 240000) + var size int64 for i := 1; i < len(arg)-1; i += 2 { + if arg[i] == nfs.SIZE { + size = kit.Int64(arg[i+1]) + } if arg[i] == SPIDE_CACHE { if t, e := time.ParseInLocation(ice.MOD_TIME, arg[i+1], time.Local); e == nil { cache = t @@ -191,9 +195,9 @@ func _spide_part(m *ice.Message, arg ...string) (io.Reader, string) { } if strings.HasPrefix(arg[i+1], "@") { if s, e := os.Stat(arg[i+1][1:]); e == nil { - m.Debug("local: %s cache: %s", s.ModTime(), cache) - if s.ModTime().Before(cache) { - break + m.Debug("local: %s size: %d size: %d cache: %s", s.ModTime(), s.Size(), size, cache) + if s.Size() == size && s.ModTime().Before(cache) { + // break } } if f, e := os.Open(arg[i+1][1:]); m.Assert(e) { @@ -341,8 +345,8 @@ func init() { conf := m.Confm(cli.RUNTIME, "conf") m.Cmd(SPIDE, mdb.CREATE, ice.OPS, kit.Select("http://127.0.0.1:9020", conf["ctx_ops"])) m.Cmd(SPIDE, mdb.CREATE, ice.DEV, kit.Select("http://contexts.woa.com:80", conf["ctx_dev"])) - m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com:443", conf["ctx_shy"])) - // m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://contexts.com.cn:443", conf["ctx_shy"])) + m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://contexts.com.cn:443", conf["ctx_shy"])) + // m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com:443", conf["ctx_shy"])) }}, mdb.CREATE: {Name: "create name address", Help: "添加", Hand: func(m *ice.Message, arg ...string) { _spide_create(m, m.Option(mdb.NAME), m.Option(ADDRESS))