Modify: use path package in app level

This commit is contained in:
HFO4
2020-01-04 16:21:43 +08:00
parent d94896041e
commit c23d129dbb
5 changed files with 27 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ import (
"github.com/HFO4/cloudreve/pkg/cache"
"github.com/HFO4/cloudreve/pkg/util"
"github.com/jinzhu/gorm"
"path/filepath"
"path"
"strconv"
"time"
)
@@ -96,7 +96,7 @@ func (policy *Policy) SerializeOptions() (err error) {
}
// GeneratePath 生成存储文件的路径
func (policy *Policy) GeneratePath(uid uint, path string) string {
func (policy *Policy) GeneratePath(uid uint, origin string) string {
dirRule := policy.DirNameRule
replaceTable := map[string]string{
"{randomkey16}": util.RandStringRunes(16),
@@ -105,10 +105,10 @@ func (policy *Policy) GeneratePath(uid uint, path string) string {
"{uid}": strconv.Itoa(int(uid)),
"{datetime}": time.Now().Format("20060102150405"),
"{date}": time.Now().Format("20060102"),
"{path}": path + "/",
"{path}": origin + "/",
}
dirRule = util.Replace(replaceTable, dirRule)
return filepath.Clean(dirRule)
return path.Clean(dirRule)
}
// GenerateFileName 生成存储文件名