fix(dashboard): cannot save settings for anonymous group

pull/2596/head
Aaron Liu 2025-06-26 18:48:07 +08:00
parent dc611bcb0d
commit 4562042b8d
1 changed files with 16 additions and 9 deletions

View File

@ -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)
} }
res, err := c.client.Group.UpdateOne(group). return stm.Save(ctx)
}
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
} }