mirror of https://github.com/cloudreve/Cloudreve
fix(dashboard): cannot save settings for anonymous group
parent
dc611bcb0d
commit
4562042b8d
|
@ -77,27 +77,34 @@ func (c *groupClient) ListAll(ctx context.Context) ([]*ent.Group, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *groupClient) Upsert(ctx context.Context, group *ent.Group) (*ent.Group, error) {
|
func (c *groupClient) Upsert(ctx context.Context, group *ent.Group) (*ent.Group, error) {
|
||||||
|
|
||||||
if group.ID == 0 {
|
if group.ID == 0 {
|
||||||
return c.client.Group.Create().
|
stm := c.client.Group.Create().
|
||||||
SetName(group.Name).
|
SetName(group.Name).
|
||||||
SetMaxStorage(group.MaxStorage).
|
SetMaxStorage(group.MaxStorage).
|
||||||
SetSpeedLimit(group.SpeedLimit).
|
SetSpeedLimit(group.SpeedLimit).
|
||||||
SetPermissions(group.Permissions).
|
SetPermissions(group.Permissions).
|
||||||
SetSettings(group.Settings).
|
SetSettings(group.Settings)
|
||||||
SetStoragePoliciesID(group.Edges.StoragePolicies.ID).
|
|
||||||
Save(ctx)
|
if group.StoragePolicyID > 0 {
|
||||||
|
stm.SetStoragePolicyID(group.StoragePolicyID)
|
||||||
|
}
|
||||||
|
|
||||||
|
return stm.Save(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Group.UpdateOne(group).
|
stm := c.client.Group.UpdateOne(group).
|
||||||
SetName(group.Name).
|
SetName(group.Name).
|
||||||
SetMaxStorage(group.MaxStorage).
|
SetMaxStorage(group.MaxStorage).
|
||||||
SetSpeedLimit(group.SpeedLimit).
|
SetSpeedLimit(group.SpeedLimit).
|
||||||
SetPermissions(group.Permissions).
|
SetPermissions(group.Permissions).
|
||||||
SetSettings(group.Settings).
|
SetSettings(group.Settings).
|
||||||
ClearStoragePolicies().
|
ClearStoragePolicies()
|
||||||
SetStoragePoliciesID(group.Edges.StoragePolicies.ID).
|
|
||||||
Save(ctx)
|
if group.StoragePolicyID > 0 {
|
||||||
|
stm.SetStoragePolicyID(group.StoragePolicyID)
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := stm.Save(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue