This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
generated from beyondstorage/go-service-example
-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Some error in storage is not handled #23
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: bokket <[email protected]>
Signed-off-by: bokket <[email protected]>
Signed-off-by: bokket <[email protected]>
Signed-off-by: bokket <[email protected]>
@Xuanwo Please help me review |
Xuanwo
reviewed
Sep 6, 2021
storage.go
Outdated
// Omit `file not exist` error here | ||
// ref: [GSP-46](https://github.com/beyondstorage/specs/blob/master/rfcs/46-idempotent-delete.md) | ||
err = nil | ||
if err != nil && errors.Is(err, os.ErrNotExist) { |
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.
How about keep complex logic out of the scope?
I prefer:
if err == nil {
// remove xxx (check error please)
}
if err != nil && !errors.Is(err, os.ErrNotExist) {
// other error happens.
}
// File is not exist, we can create now.
Signed-off-by: bokket <[email protected]>
Signed-off-by: bokket <[email protected]>
Xuanwo
reviewed
Sep 7, 2021
storage.go
Outdated
// Omit `file not exist` error here | ||
// ref: [GSP-46](https://github.com/beyondstorage/specs/blob/master/rfcs/46-idempotent-delete.md) | ||
err = nil | ||
// If the path does not exist, |
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.
If the error returned by Stat
is nil, the path must exist. I think we don't need to explain the detailed behavior of our hdfs SDK. Instead, we need to comment on why we need to do remove it here.
storage.go
Outdated
// If the path does not exist, | ||
// RemoveAll returns nil (no error). | ||
// If there is an error here other than os.ErrNotExist is also thrown directly | ||
err = s.hdfs.RemoveAll(rp) |
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.
RemoveAll
is not a good idea. As we only allow remove one object at a time.
Signed-off-by: bokket <[email protected]>
Signed-off-by: bokket <[email protected]>
Xuanwo
changed the title
ci:Fix dependabot automatic update merge error
fix: Some error in storage is not handled
Sep 8, 2021
Xuanwo
approved these changes
Sep 8, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: bokket [email protected]