Fix: nil pointer and initial policy file type wildcard

This commit is contained in:
HFO4 2020-03-10 12:10:30 +08:00
parent 27e1da8238
commit cb57fdbb59
2 changed files with 1 additions and 4 deletions

View file

@ -66,9 +66,6 @@ func addDefaultPolicy() {
DirNameRule: "uploads/{uid}/{path}",
FileNameRule: "{uid}_{randomkey8}_{originname}",
IsOriginLinkEnable: false,
OptionsSerialized: PolicyOption{
FileType: []string{},
},
}
if err := DB.Create(&defaultPolicy).Error; err != nil {
util.Log().Panic("无法创建初始存储策略, %s", err)

View file

@ -30,7 +30,7 @@ func collectArchiveFile() {
// 列出文件
root := filepath.Join(tempPath, "archive")
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil && !info.IsDir() &&
if err == nil && !info.IsDir() &&
strings.HasPrefix(filepath.Base(path), "archive_") &&
time.Now().Sub(info.ModTime()).Seconds() > float64(expires) {
util.Log().Debug("删除过期打包下载临时文件 [%s]", path)