fsutil: Defensive check for Stat cast
This commit is contained in:
parent
834a6148b0
commit
560a127ce6
@ -21,7 +21,10 @@ func FileSize(path string) (SizeInfo, error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !info.IsDir() {
|
if !info.IsDir() {
|
||||||
stat := info.Sys().(*syscall.Stat_t)
|
stat, ok := info.Sys().(*syscall.Stat_t)
|
||||||
|
if !ok {
|
||||||
|
return xerrors.New("FileInfo.Sys of wrong type")
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: stat.Blocks is in 512B blocks, NOT in stat.Blksize return SizeInfo{size}, nil
|
// NOTE: stat.Blocks is in 512B blocks, NOT in stat.Blksize return SizeInfo{size}, nil
|
||||||
// See https://www.gnu.org/software/libc/manual/html_node/Attribute-Meanings.html
|
// See https://www.gnu.org/software/libc/manual/html_node/Attribute-Meanings.html
|
||||||
|
Loading…
Reference in New Issue
Block a user