Skip to content

Commit

Permalink
Merge pull request #240 from pixlise/feature/multi-quant
Browse files Browse the repository at this point in the history
Fix auto-quant auto-share
  • Loading branch information
pnemere authored Jun 11, 2024
2 parents b14cb23 + ae16088 commit 3208330
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions api/quantification/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,25 +388,25 @@ func (r *quantNodeRunner) triggerPiquantNodes(wg *sync.WaitGroup) {
}

// If we've got a special import that's done by the internal user, we read the owner entry from DB scan auto share table (ScanAutoShareName)
var ownerItem *protos.OwnershipItem
ownerItem := wsHelpers.MakeOwnerForWrite(r.jobId, protos.ObjectType_OT_QUANTIFICATION, r.quantStartSettings.RequestorUserId, now)
if r.quantStartSettings.RequestorUserId == specialUserIds.PIXLISESystemUserId {
coll := svcs.MongoDB.Collection(dbCollections.ScanAutoShareName)
autoShareResult := coll.FindOne(context.TODO(), bson.D{{Key: "_id", Value: r.quantStartSettings.RequestorUserId}}, options.FindOne())
if autoShareResult.Err() != nil {
svcs.Log.Errorf("Failed to read auto-share info for quantification triggered by %v. Quant won't be shared", r.quantStartSettings.RequestorUserId)
} else {
err := autoShareResult.Decode(ownerItem)
autoEntry := &protos.ScanAutoShareEntry{}
err := autoShareResult.Decode(autoEntry)
if err != nil {
svcs.Log.Errorf("Failed to decode auto-share info for quantification triggered by %v: %v", r.quantStartSettings.RequestorUserId, err)
ownerItem = nil
} else {
svcs.Log.Errorf("Found scan auto-share entry for quantification requestor \"%v\". Sharing accordingly.", r.quantStartSettings.RequestorUserId)
ownerItem.Viewers = autoEntry.Viewers
ownerItem.Editors = autoEntry.Editors
}
}
}

if ownerItem == nil {
ownerItem = wsHelpers.MakeOwnerForWrite(r.jobId, protos.ObjectType_OT_QUANTIFICATION, r.quantStartSettings.RequestorUserId, now)
}

err = writeQuantAndOwnershipToDB(summary, ownerItem, svcs.MongoDB)
if err != nil {
r.completeJobState(false, fmt.Sprintf("Failed to write quantification and ownership to DB: %v. Id: %v", err, r.jobId), quantOutPath, piquantLogList)
Expand Down

0 comments on commit 3208330

Please sign in to comment.