-
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
Changes from all commits
f4406e1
dc944b4
ebe7881
c1fd157
6985d44
8f04c0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -423,19 +423,26 @@ func (fsh *StorageHandler) DownloadFile( | |
| "couldn't save latest read marker: %v", err) | ||
| } | ||
|
|
||
| if len(fileref.EncryptedKey) > 0 { | ||
| if authToken == nil { | ||
| return nil, errors.New("auth ticket is required to download encrypted file") | ||
| } | ||
| // check if client is authorized to download | ||
| shareInfo, err := reference.GetShareInfo( | ||
| var shareInfo *reference.ShareInfo | ||
| if authToken != nil { | ||
| shareInfo, err = reference.GetShareInfo( | ||
| ctx, | ||
| readMarker.ClientID, | ||
| authToken.FilePathHash, | ||
| ) | ||
| if err != nil { | ||
| return nil, errors.New("error during share info lookup in database" + err.Error()) | ||
| } else if shareInfo == nil || shareInfo.Revoked { | ||
|
|
||
| if err == nil && shareInfo.Revoked { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| return nil, errors.New("client does not have permission to download the file. share revoked") | ||
| } | ||
| } | ||
|
|
||
| if len(fileref.EncryptedKey) > 0 { | ||
| if authToken == nil { | ||
| return nil, errors.New("auth ticket is required to download encrypted file") | ||
| } | ||
|
|
||
| // should not happen, just in case | ||
| if shareInfo == nil { | ||
| return nil, errors.New("client does not have permission to download the file. share does not exist") | ||
| } | ||
|
|
||
|
|
@@ -450,9 +457,6 @@ func (fsh *StorageHandler) DownloadFile( | |
| if err := encscheme.InitForDecryption("filetype:audio", fileref.EncryptedKey); err != nil { | ||
| return nil, err | ||
| } | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| totalSize := len(respData) | ||
| result := []byte{} | ||
|
|
||
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?
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