-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Wire ctx to getdag operations in gc.GC #2221
Conversation
rht
commented
Jan 21, 2016
- potentially address Panic when doing 'ipfs cat' #2220
cc @whyrusleeping pls CR |
|
@rht i think this LGTM. but tests first. |
@@ -562,7 +562,9 @@ func (r *FSRepo) GetStorageUsage() (uint64, error) { | |||
|
|||
var du uint64 | |||
err = filepath.Walk(pth, func(p string, f os.FileInfo, err error) error { | |||
du += uint64(f.Size()) | |||
if f != 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.
we really should check the error here and at least log it
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 there is err
, it will get returned by the function GetStorageUsage
anyway.
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.
but the error inside this function is different than the error returned from filepath.Walk
. The error passed into the function here is one that comes from calling stat on the path we're also passed. The one from filepath.Walk
is whatever we return from our function
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.
The stat is called from the filepath.Walk
(https://golang.org/src/path/filepath/path.go#L368). The specific walkFn
call here doesn't return any err value unless if a nil
stat is considered 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.
what i'm saying is that the err in our walkfunc is any error that gets returned from the lstat you link to. I'm saying that we should log that error just in case. I'm always against blanket ignoring errors.
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.
The err is returned by GetStorageUsage
, and is already logged by the caller.
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.
err = filepath.Walk(pth, func(p string, f os.FileInfo, err error) error {
if err != nil {
log.Debugf("filepath.Walk error: %s", err)
return nil
}
du += uint64(f.Size())
return 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.
There is already https://github.com/ipfs/go-ipfs/blob/eb9d0729280669b1e277b082cc28c45c87038020/core/corerepo/gc.go#L147. I added the log, however.
@jbenet that panic is just to do with a quick hack i'm using in testing. Nothing that will actually affect the codebase. We could do one of those fancy schmancy 'close the channel only if its not already closed' checks to make that panic never happen again though |
Which I assume that 'close the channel only if its not already closed' is done in the rest of the codebase that is not test? |
correct. The channel closing in question is inside of a testwriter struct thats only used in testing. |
License: MIT Signed-off-by: rht <[email protected]>
Wire ctx to getdag operations in gc.GC