diff --git a/satellite/admin/project.go b/satellite/admin/project.go index 0c7b8e8ab..1fab4ccf2 100644 --- a/satellite/admin/project.go +++ b/satellite/admin/project.go @@ -684,7 +684,7 @@ func (server *Server) createGeofenceForProject(w http.ResponseWriter, r *http.Re } func (server *Server) deleteGeofenceForProject(w http.ResponseWriter, r *http.Request) { - server.setGeofenceForProject(w, r, storj.EveryCountry) + server.setGeofenceForProject(w, r, storj.DefaultPlacement) } func (server *Server) setGeofenceForProject(w http.ResponseWriter, r *http.Request, placement storj.PlacementConstraint) { @@ -711,9 +711,7 @@ func (server *Server) setGeofenceForProject(w http.ResponseWriter, r *http.Reque } - project.DefaultPlacement = placement - - err = server.db.Console().Projects().Update(ctx, project) + err = server.db.Console().Projects().UpdateDefaultPlacement(ctx, project.ID, placement) if err != nil { sendJSONError(w, "unable to set geofence for project", err.Error(), http.StatusInternalServerError) diff --git a/satellite/console/projects.go b/satellite/console/projects.go index e701404cf..a21151e92 100644 --- a/satellite/console/projects.go +++ b/satellite/console/projects.go @@ -58,6 +58,9 @@ type Projects interface { // UpdateUserAgent is a method for updating projects user agent. UpdateUserAgent(ctx context.Context, id uuid.UUID, userAgent []byte) error + + // UpdateDefaultPlacement is a method to update the project's default placement for new segments. + UpdateDefaultPlacement(ctx context.Context, id uuid.UUID, placement storj.PlacementConstraint) error } // UsageLimitsConfig is a configuration struct for default per-project usage limits. diff --git a/satellite/satellitedb/projects.go b/satellite/satellitedb/projects.go index 05fb455bc..3c0b026e6 100644 --- a/satellite/satellitedb/projects.go +++ b/satellite/satellitedb/projects.go @@ -324,6 +324,21 @@ func (projects *projects) UpdateUserAgent(ctx context.Context, id uuid.UUID, use return err } +// UpdateDefaultPlacement is a method to update the project's default placement for new segments. +func (projects *projects) UpdateDefaultPlacement(ctx context.Context, id uuid.UUID, placement storj.PlacementConstraint) (err error) { + defer mon.Task()(&ctx)(&err) + + _, err = projects.db.Update_Project_By_Id( + ctx, + dbx.Project_Id(id[:]), + dbx.Project_Update_Fields{ + DefaultPlacement: dbx.Project_DefaultPlacement(int(placement)), + }, + ) + + return err +} + // List returns paginated projects, created before provided timestamp. func (projects *projects) List(ctx context.Context, offset int64, limit int, before time.Time) (_ console.ProjectsPage, err error) { defer mon.Task()(&ctx)(&err)