Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/image only scans #238

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/ws/handlers/image-beam-location.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ func HandleImageBeamLocationsReq(req *protos.ImageBeamLocationsReq, hctx wsHelpe
result := coll.FindOne(ctx, bson.M{"_id": req.ImageName})
if result.Err() != nil {
if result.Err() == mongo.ErrNoDocuments {
return nil, errorwithstatus.MakeNotFoundError(req.ImageName)
// If there are no beam locations, don't return an error, just return a message with no items in it
return &protos.ImageBeamLocationsResp{
Locations: &protos.ImageLocations{ImageName: req.ImageName},
}, nil
}
return nil, result.Err()
}
Expand Down
9 changes: 6 additions & 3 deletions api/ws/handlers/quantification-multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
protos "github.com/pixlise/core/v4/generated-protos"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)

// Anyone can retrieve a quant z-stack if they have quant messaging permissions
Expand Down Expand Up @@ -65,13 +66,15 @@ func HandleQuantCombineListWriteReq(req *protos.QuantCombineListWriteReq, hctx w
List: req.List,
}

result, err := coll.InsertOne(ctx, doc)
opt := options.Update().SetUpsert(true)

result, err := coll.UpdateByID(ctx, zId, bson.D{{Key: "$set", Value: doc}}, opt)
if err != nil {
return nil, err
}

if result.InsertedID != zId {
hctx.Svcs.Log.Errorf("MultiQuant Z-Stack insert %v inserted different id %v", zId, result.InsertedID)
if result.UpsertedCount != 1 {
hctx.Svcs.Log.Errorf("MultiQuant Z-Stack write for: %v got unexpected DB write result: %+v", req.ScanId, result)
}

return &protos.QuantCombineListWriteResp{}, nil
Expand Down
2 changes: 1 addition & 1 deletion data-formats
9 changes: 6 additions & 3 deletions internal/cmd-line-tools/api-integration-test/testScanData.go
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,12 @@ func testScanDataHasPermission(apiHost string, actionMsg string, editAllowed boo
`{"imageBeamLocationsReq":{"imageName": "non-existant.jpg"}}`,
`{
"msgId": 12,
"status": "WS_NOT_FOUND",
"errorText": "non-existant.jpg not found",
"imageBeamLocationsResp": {}
"status": "WS_OK",
"imageBeamLocationsResp": {
"locations": {
"imageName": "non-existant.jpg"
}
}
}`,
)

Expand Down
Loading