764bbd98 by slene

#390 should use filepath.Dir instead of path.Dir for.

1 parent 67b9c635
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
14 "fmt" 14 "fmt"
15 "io" 15 "io"
16 "os" 16 "os"
17 "path" 17 "path/filepath"
18 "reflect" 18 "reflect"
19 "strconv" 19 "strconv"
20 "time" 20 "time"
...@@ -79,8 +79,8 @@ func (this *FileCache) StartAndGC(config string) error { ...@@ -79,8 +79,8 @@ func (this *FileCache) StartAndGC(config string) error {
79 } 79 }
80 80
81 func (this *FileCache) Init() { 81 func (this *FileCache) Init() {
82 app := path.Dir(os.Args[0]) 82 app := filepath.Dir(os.Args[0])
83 this.CachePath = path.Join(app, this.CachePath) 83 this.CachePath = filepath.Join(app, this.CachePath)
84 ok, err := exists(this.CachePath) 84 ok, err := exists(this.CachePath)
85 if err != nil { // print error 85 if err != nil { // print error
86 //fmt.Println(err) 86 //fmt.Println(err)
...@@ -102,9 +102,9 @@ func (this *FileCache) getCacheFileName(key string) string { ...@@ -102,9 +102,9 @@ func (this *FileCache) getCacheFileName(key string) string {
102 //fmt.Println("md5" , keyMd5); 102 //fmt.Println("md5" , keyMd5);
103 switch this.DirectoryLevel { 103 switch this.DirectoryLevel {
104 case 2: 104 case 2:
105 cachePath = path.Join(cachePath, keyMd5[0:2], keyMd5[2:4]) 105 cachePath = filepath.Join(cachePath, keyMd5[0:2], keyMd5[2:4])
106 case 1: 106 case 1:
107 cachePath = path.Join(cachePath, keyMd5[0:2]) 107 cachePath = filepath.Join(cachePath, keyMd5[0:2])
108 } 108 }
109 109
110 ok, err := exists(cachePath) 110 ok, err := exists(cachePath)
...@@ -116,7 +116,7 @@ func (this *FileCache) getCacheFileName(key string) string { ...@@ -116,7 +116,7 @@ func (this *FileCache) getCacheFileName(key string) string {
116 //fmt.Println(err); 116 //fmt.Println(err);
117 } 117 }
118 } 118 }
119 return path.Join(cachePath, fmt.Sprintf("%s%s", keyMd5, this.FileSuffix)) 119 return filepath.Join(cachePath, fmt.Sprintf("%s%s", keyMd5, this.FileSuffix))
120 } 120 }
121 121
122 func (this *FileCache) Get(key string) interface{} { 122 func (this *FileCache) Get(key string) interface{} {
......
...@@ -7,7 +7,6 @@ import ( ...@@ -7,7 +7,6 @@ import (
7 "io/ioutil" 7 "io/ioutil"
8 "log" 8 "log"
9 "os" 9 "os"
10 "path"
11 "path/filepath" 10 "path/filepath"
12 "strings" 11 "strings"
13 "sync" 12 "sync"
...@@ -201,7 +200,7 @@ func (w *FileLogWriter) DoRotate() error { ...@@ -201,7 +200,7 @@ func (w *FileLogWriter) DoRotate() error {
201 } 200 }
202 201
203 func (w *FileLogWriter) deleteOldLog() { 202 func (w *FileLogWriter) deleteOldLog() {
204 dir := path.Dir(w.Filename) 203 dir := filepath.Dir(w.Filename)
205 filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { 204 filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
206 if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) { 205 if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) {
207 if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) { 206 if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!