From 81acbbdf31e9e11759a522acef202a34feac3835 Mon Sep 17 00:00:00 2001 From: godcong Date: Sun, 13 Oct 2019 03:50:31 +0800 Subject: [PATCH] update javbus --- grab_test.go | 12 ++++++++++++ scrape.go | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/grab_test.go b/grab_test.go index 0f835ec..6672e93 100644 --- a/grab_test.go +++ b/grab_test.go @@ -1,6 +1,7 @@ package scrape import ( + "os" "testing" "github.com/javscrape/go-scrape/net" @@ -32,3 +33,14 @@ func TestGrabJAVBUS_Find(t *testing.T) { t.Fatal(err) } } +func TestStat(t *testing.T) { + info, e := os.Stat("grab_test.go") + t.Log(os.IsNotExist(e)) + t.Log(os.IsExist(e)) + t.Log(info, e) + + info1, e1 := os.Stat("grab_test1.go") + t.Log(os.IsNotExist(e1)) + t.Log(os.IsExist(e1)) + t.Log(info1, e1) +} diff --git a/scrape.go b/scrape.go index 9a2fac7..3390c48 100644 --- a/scrape.go +++ b/scrape.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "strconv" + "strings" "github.com/javscrape/go-scrape/net" ) @@ -111,7 +112,7 @@ func (impl *scrapeImpl) Find(name string) (msg *[]*Content, e error) { } func copyCache(cache *net.Cache, msg *Content, output string) (e error) { - pid := filepath.Join(output, msg.ID) + pid := filepath.Join(output, strings.ToUpper(msg.ID)) e = copyFile(cache, msg.Image, filepath.Join(pid, "image")) if e != nil { return e @@ -140,7 +141,7 @@ func copyCache(cache *net.Cache, msg *Content, output string) (e error) { } func copyInfo(msg *Content, path string) error { - pid := filepath.Join(path, msg.ID) + pid := filepath.Join(path, strings.ToUpper(msg.ID)) inf := filepath.Join(pid, "inf.json") _ = os.MkdirAll(filepath.Dir(inf), os.ModePerm) info, e := os.Stat(inf)