Refactor Docker and Makefile configurations for improved build processes
- Updated docker-compose.tools.yml to mount source code at /src and set working directory for backend tools, ensuring proper Go module caching. - Modified Dockerfile.tools to install the latest golangci-lint version compatible with Go 1.24 and adjusted working directory for build-time operations. - Enhanced Makefile to build backend tools before running tests and linting, ensuring dependencies are up-to-date and improving overall workflow efficiency. - Refactored test and handler files to include error handling for database operations, enhancing reliability and debugging capabilities.
This commit is contained in:
@@ -141,7 +141,9 @@ func (s *ClientService) ProcessGridUpdate(ctx context.Context, grup GridUpdate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
grids.Put([]byte(grid), raw)
|
||||
if err := grids.Put([]byte(grid), raw); err != nil {
|
||||
return err
|
||||
}
|
||||
greq.GridRequests = append(greq.GridRequests, grid)
|
||||
}
|
||||
}
|
||||
@@ -192,7 +194,9 @@ func (s *ClientService) ProcessGridUpdate(ctx context.Context, grup GridUpdate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
grids.Put([]byte(grid), raw)
|
||||
if err := grids.Put([]byte(grid), raw); err != nil {
|
||||
return err
|
||||
}
|
||||
greq.GridRequests = append(greq.GridRequests, grid)
|
||||
}
|
||||
}
|
||||
@@ -207,7 +211,7 @@ func (s *ClientService) ProcessGridUpdate(ctx context.Context, grup GridUpdate)
|
||||
}
|
||||
}
|
||||
if len(maps) > 1 {
|
||||
grids.ForEach(func(k, v []byte) error {
|
||||
if err := grids.ForEach(func(k, v []byte) error {
|
||||
gd := app.GridData{}
|
||||
if err := json.Unmarshal(v, &gd); err != nil {
|
||||
return err
|
||||
@@ -244,16 +248,22 @@ func (s *ClientService) ProcessGridUpdate(ctx context.Context, grup GridUpdate)
|
||||
File: td.File,
|
||||
})
|
||||
}
|
||||
grids.Put(k, raw)
|
||||
if err := grids.Put(k, raw); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for mergeid, merge := range maps {
|
||||
if mapid == mergeid {
|
||||
continue
|
||||
}
|
||||
mapB.Delete([]byte(strconv.Itoa(mergeid)))
|
||||
if err := mapB.Delete([]byte(strconv.Itoa(mergeid))); err != nil {
|
||||
return err
|
||||
}
|
||||
slog.Info("reporting merge", "from", mergeid, "to", mapid)
|
||||
s.mapSvc.ReportMerge(mergeid, mapid, app.Coord{X: offset.X - merge.X, Y: offset.Y - merge.Y})
|
||||
}
|
||||
@@ -271,10 +281,10 @@ func (s *ClientService) ProcessGridUpdate(ctx context.Context, grup GridUpdate)
|
||||
func (s *ClientService) ProcessGridUpload(ctx context.Context, id string, extraData string, fileReader io.Reader) error {
|
||||
if extraData != "" {
|
||||
ed := ExtraData{}
|
||||
json.Unmarshal([]byte(extraData), &ed)
|
||||
_ = json.Unmarshal([]byte(extraData), &ed)
|
||||
if ed.Season == 3 {
|
||||
needTile := false
|
||||
s.st.Update(ctx, func(tx *bbolt.Tx) error {
|
||||
if err := s.st.Update(ctx, func(tx *bbolt.Tx) error {
|
||||
raw := s.st.GetGrid(tx, id)
|
||||
if raw == nil {
|
||||
return fmt.Errorf("unknown grid id: %s", id)
|
||||
@@ -301,7 +311,9 @@ func (s *ClientService) ProcessGridUpload(ctx context.Context, id string, extraD
|
||||
}
|
||||
raw, _ = json.Marshal(cur)
|
||||
return s.st.PutGrid(tx, id, raw)
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if !needTile {
|
||||
slog.Debug("ignoring tile upload: winter")
|
||||
return nil
|
||||
@@ -316,7 +328,7 @@ func (s *ClientService) ProcessGridUpload(ctx context.Context, id string, extraD
|
||||
cur := app.GridData{}
|
||||
mapid := 0
|
||||
|
||||
s.st.Update(ctx, func(tx *bbolt.Tx) error {
|
||||
if err := s.st.Update(ctx, func(tx *bbolt.Tx) error {
|
||||
raw := s.st.GetGrid(tx, id)
|
||||
if raw == nil {
|
||||
return fmt.Errorf("unknown grid id: %s", id)
|
||||
@@ -331,7 +343,9 @@ func (s *ClientService) ProcessGridUpload(ctx context.Context, id string, extraD
|
||||
}
|
||||
raw, _ = json.Marshal(cur)
|
||||
return s.st.PutGrid(tx, id, raw)
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if updateTile {
|
||||
gridDir := fmt.Sprintf("%s/grids", s.mapSvc.GridStorage())
|
||||
@@ -374,7 +388,7 @@ func (s *ClientService) UpdatePositions(ctx context.Context, data []byte) error
|
||||
}
|
||||
|
||||
gridDataByID := make(map[string]app.GridData)
|
||||
s.st.View(ctx, func(tx *bbolt.Tx) error {
|
||||
if err := s.st.View(ctx, func(tx *bbolt.Tx) error {
|
||||
for _, craw := range craws {
|
||||
raw := s.st.GetGrid(tx, craw.GridID)
|
||||
if raw != nil {
|
||||
@@ -385,7 +399,9 @@ func (s *ClientService) UpdatePositions(ctx context.Context, data []byte) error
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
username, _ := ctx.Value(app.ClientUsernameKey).(string)
|
||||
|
||||
@@ -478,8 +494,12 @@ func (s *ClientService) UploadMarkers(ctx context.Context, data []byte) error {
|
||||
Image: img,
|
||||
}
|
||||
raw, _ := json.Marshal(m)
|
||||
grid.Put(key, raw)
|
||||
idB.Put(idKey, key)
|
||||
if err := grid.Put(key, raw); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := idB.Put(idKey, key); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user