mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 02:50:55 +00:00
#390 should use filepath.Dir instead of path.Dir for.
This commit is contained in:
parent
67b9c63528
commit
764bbd9897
12
cache/file.go
vendored
12
cache/file.go
vendored
@ -14,7 +14,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -79,8 +79,8 @@ func (this *FileCache) StartAndGC(config string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *FileCache) Init() {
|
func (this *FileCache) Init() {
|
||||||
app := path.Dir(os.Args[0])
|
app := filepath.Dir(os.Args[0])
|
||||||
this.CachePath = path.Join(app, this.CachePath)
|
this.CachePath = filepath.Join(app, this.CachePath)
|
||||||
ok, err := exists(this.CachePath)
|
ok, err := exists(this.CachePath)
|
||||||
if err != nil { // print error
|
if err != nil { // print error
|
||||||
//fmt.Println(err)
|
//fmt.Println(err)
|
||||||
@ -102,9 +102,9 @@ func (this *FileCache) getCacheFileName(key string) string {
|
|||||||
//fmt.Println("md5" , keyMd5);
|
//fmt.Println("md5" , keyMd5);
|
||||||
switch this.DirectoryLevel {
|
switch this.DirectoryLevel {
|
||||||
case 2:
|
case 2:
|
||||||
cachePath = path.Join(cachePath, keyMd5[0:2], keyMd5[2:4])
|
cachePath = filepath.Join(cachePath, keyMd5[0:2], keyMd5[2:4])
|
||||||
case 1:
|
case 1:
|
||||||
cachePath = path.Join(cachePath, keyMd5[0:2])
|
cachePath = filepath.Join(cachePath, keyMd5[0:2])
|
||||||
}
|
}
|
||||||
|
|
||||||
ok, err := exists(cachePath)
|
ok, err := exists(cachePath)
|
||||||
@ -116,7 +116,7 @@ func (this *FileCache) getCacheFileName(key string) string {
|
|||||||
//fmt.Println(err);
|
//fmt.Println(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path.Join(cachePath, fmt.Sprintf("%s%s", keyMd5, this.FileSuffix))
|
return filepath.Join(cachePath, fmt.Sprintf("%s%s", keyMd5, this.FileSuffix))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *FileCache) Get(key string) interface{} {
|
func (this *FileCache) Get(key string) interface{} {
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -201,7 +200,7 @@ func (w *FileLogWriter) DoRotate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *FileLogWriter) deleteOldLog() {
|
func (w *FileLogWriter) deleteOldLog() {
|
||||||
dir := path.Dir(w.Filename)
|
dir := filepath.Dir(w.Filename)
|
||||||
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
||||||
if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) {
|
if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) {
|
||||||
if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) {
|
if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user