* fix:修复webdav上传图片时无缩略图问题 * 修改 Trim 为 TrimRight * 1.增加图片生成缩略图时自动识别EXIF信息并存储到数据库 2.修改迁移配置、manage 接口返回文件增加 exif 信息字段 3.计划任务增加自动识别将经纬度转换为文本地址任务 * 变更assets * fix:修复前端页面合并遗留bug * 1. 将获取更新EXIF地址的文件列表函数更名为 GetEmptyLocationFilesByPage 2.页面API展示列表接口增加过滤默认空时间 * update assets
44 lines
966 B
Go
44 lines
966 B
Go
package crontab
|
|
|
|
import (
|
|
model "github.com/cloudreve/Cloudreve/v3/models"
|
|
"github.com/cloudreve/Cloudreve/v3/pkg/util"
|
|
"github.com/robfig/cron/v3"
|
|
)
|
|
|
|
// Cron 定时任务
|
|
var Cron *cron.Cron
|
|
|
|
// Reload 重新启动定时任务
|
|
func Reload() {
|
|
if Cron != nil {
|
|
Cron.Stop()
|
|
}
|
|
Init()
|
|
}
|
|
|
|
// Init 初始化定时任务
|
|
func Init() {
|
|
util.Log().Info("初始化定时任务...")
|
|
// 读取cron日程设置
|
|
options := model.GetSettingByNames("cron_garbage_collect","cron_sync_photo_lat_long_to_address")
|
|
Cron := cron.New()
|
|
for k, v := range options {
|
|
var handler func()
|
|
switch k {
|
|
case "cron_garbage_collect":
|
|
handler = garbageCollect
|
|
case "cron_sync_photo_lat_long_to_address":
|
|
handler = syncPhotoAddress
|
|
default:
|
|
util.Log().Warning("未知定时任务类型 [%s],跳过", k)
|
|
continue
|
|
}
|
|
|
|
if _, err := Cron.AddFunc(v, handler); err != nil {
|
|
util.Log().Warning("无法启动定时任务 [%s] , %s", k, err)
|
|
}
|
|
|
|
}
|
|
Cron.Start()
|
|
}
|