Fix: absolute path cannot be saved for new policy

This commit is contained in:
HFO4 2020-03-18 10:45:33 +08:00
parent 87fde687eb
commit 175c4d781f

View file

@ -244,7 +244,9 @@ func (service *SlaveTestService) Test() serializer.Response {
// Add 添加存储策略
func (service *AddPolicyService) Add() serializer.Response {
service.Policy.DirNameRule = strings.TrimPrefix(service.Policy.DirNameRule, "/")
if service.Policy.Type != "local" && service.Policy.Type != "remote" {
service.Policy.DirNameRule = strings.TrimPrefix(service.Policy.DirNameRule, "/")
}
if service.Policy.ID > 0 {
if err := model.DB.Save(&service.Policy).Error; err != nil {