-
Notifications
You must be signed in to change notification settings - Fork 26
Fix with revoked share #297
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
Conversation
| existingShare, err := reference.GetShareInfo(ctx, authTicket.ClientID, authTicket.FilePathHash) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we check err here? We need to know if db throw any error?
func GetShareInfo(ctx context.Context, clientID string, filePathHash string) (*ShareInfo, error) {
db := datastore.GetStore().GetTransaction(ctx)
shareInfo := &ShareInfo{}
err := db.Table(TableName()).
Where(&ShareInfo{
ClientID: clientID,
FilePathHash: filePathHash,
}).
First(shareInfo).Error
if err == gorm.ErrRecordNotFound {
return nil, nil
}
if err != nil {
return nil, err
}
return shareInfo, nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it's wrong 'tricky' implementation that causes previous bugs. I removed this check from DB level
| return nil, errors.New("error during share info lookup in database" + err.Error()) | ||
| } else if shareInfo == nil || shareInfo.Revoked { | ||
|
|
||
| if err == nil && shareInfo.Revoked { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app might crash if shareInfo is nil? It is better to check it first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly what was done in the previous comment. It' can't be nil if err is nil.
|
here is an example for my review. thanks |
|
BTW, |
|
@cnlangzi This has to be applied globally and it's not following my current logic for sharing |
--revoke share didn't work since the last gosdk update. This fix should resolve it