Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

fix: Some error in storage is not handled #23

Merged
merged 8 commits into from
Sep 8, 2021
Merged

fix: Some error in storage is not handled #23

merged 8 commits into from
Sep 8, 2021

Conversation

bokket
Copy link
Member

@bokket bokket commented Sep 6, 2021

Signed-off-by: bokket [email protected]

@bokket
Copy link
Member Author

bokket commented Sep 6, 2021

@Xuanwo Please help me review

storage.go Show resolved Hide resolved
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) {
Copy link
Contributor

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.

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,
Copy link
Contributor

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)
Copy link
Contributor

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.

@Xuanwo Xuanwo changed the title ci:Fix dependabot automatic update merge error fix: Some error in storage is not handled Sep 8, 2021
@Xuanwo Xuanwo merged commit ceaedae into beyondstorage:master Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants